2 * This file has been commented to support Visual Studio Intellisense.
3 * You should not use this file at runtime inside the browser--it is only
4 * intended to be used only for design-time IntelliSense. Please use the
5 * standard jQuery library for all production use.
7 * Comment version: 1.3.2a
11 * jQuery JavaScript Library v1.3.2
13 * Copyright (c) 2009 John Resig, http://jquery.com/
15 * Permission is hereby granted, free of charge, to any person obtaining
16 * a copy of this software and associated documentation files (the
17 * "Software"), to deal in the Software without restriction, including
18 * without limitation the rights to use, copy, modify, merge, publish,
19 * distribute, sublicense, and/or sell copies of the Software, and to
20 * permit persons to whom the Software is furnished to do so, subject to
21 * the following conditions:
23 * The above copyright notice and this permission notice shall be
24 * included in all copies or substantial portions of the Software.
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
41 // Will speed up references to window, and allows munging its name.
43 // Will speed up references to undefined, and allows munging its name.
45 // Map over jQuery in case of overwrite
46 _jQuery
= window
.jQuery
,
47 // Map over the $ in case of overwrite
50 jQuery
= window
.jQuery
= window
.$ = function(selector
, context
) {
52 /// 1: $(expression, context) - This function accepts a string containing a CSS selector which is then used to match a set of elements.
53 /// 2: $(html) - Create DOM elements on-the-fly from the provided String of raw HTML.
54 /// 3: $(elements) - Wrap jQuery functionality around a single or multiple DOM Element(s).
55 /// 4: $(callback) - A shorthand for $(document).ready().
57 /// <param name="selector" type="String">
58 /// 1: expression - An expression to search with.
59 /// 2: html - A string of HTML to create on the fly.
60 /// 3: elements - DOM element(s) to be encapsulated by a jQuery object.
61 /// 4: callback - The function to execute when the DOM is ready.
63 /// <param name="context" type="jQuery">
64 /// 1: context - A DOM Element, Document or jQuery to use as context.
66 /// <field name="selector" Type="Object">
67 /// The DOM node context originally passed to jQuery() (if none was passed then context will be equal to the document).
69 /// <field name="context" Type="String">
70 /// A selector representing selector originally passed to jQuery().
72 /// <returns type="jQuery" />
74 // The jQuery object is actually just the init constructor 'enhanced'
75 return new jQuery
.fn
.init( selector
, context
);
78 // A simple way to check for HTML strings or ID strings
79 // (both of which we optimize for)
80 quickExpr
= /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,
81 // Is it a simple selector
82 isSimple
= /^.[^:#\[\.,]*$/;
84 jQuery
.fn
= jQuery
.prototype = {
85 init: function( selector
, context
) {
87 /// 1: $(expression, context) - This function accepts a string containing a CSS selector which is then used to match a set of elements.
88 /// 2: $(html) - Create DOM elements on-the-fly from the provided String of raw HTML.
89 /// 3: $(elements) - Wrap jQuery functionality around a single or multiple DOM Element(s).
90 /// 4: $(callback) - A shorthand for $(document).ready().
92 /// <param name="selector" type="String">
93 /// 1: expression - An expression to search with.
94 /// 2: html - A string of HTML to create on the fly.
95 /// 3: elements - DOM element(s) to be encapsulated by a jQuery object.
96 /// 4: callback - The function to execute when the DOM is ready.
98 /// <param name="context" type="jQuery">
99 /// 1: context - A DOM Element, Document or jQuery to use as context.
101 /// <returns type="jQuery" />
103 // Make sure that a selection was provided
104 selector
= selector
|| document
;
106 // Handle $(DOMElement)
107 if ( selector
.nodeType
) {
110 this.context
= selector
;
113 // Handle HTML strings
114 if (typeof selector
=== "string") {
115 // Are we dealing with HTML string or an ID?
116 var match
= quickExpr
.exec(selector
);
118 // Verify a match, and that no context was specified for #id
119 if (match
&& (match
[1] || !context
)) {
121 // HANDLE: $(html) -> $(array)
123 selector
= jQuery
.clean([match
[1]], context
);
127 var elem
= document
.getElementById(match
[3]);
129 // Handle the case where IE and Opera return items
130 // by name instead of ID
131 if (elem
&& elem
.id
!= match
[3])
132 return jQuery().find(selector
);
134 // Otherwise, we inject the element directly into the jQuery object
135 var ret
= jQuery(elem
|| []);
136 ret
.context
= document
;
137 ret
.selector
= selector
;
141 // HANDLE: $(expr, [context])
142 // (which is just equivalent to: $(content).find(expr)
144 return jQuery(context
).find(selector
);
146 // HANDLE: $(function)
147 // Shortcut for document ready
148 } else if ( jQuery
.isFunction( selector
) )
149 return jQuery( document
).ready( selector
);
151 // Make sure that old selector state is passed along
152 if ( selector
.selector
&& selector
.context
) {
153 this.selector
= selector
.selector
;
154 this.context
= selector
.context
;
157 return this.setArray(jQuery
.isArray( selector
) ?
159 jQuery
.makeArray(selector
));
162 // Start with an empty selector
165 // The current version of jQuery being used
168 // The number of elements contained in the matched element set
171 /// The number of elements currently matched.
174 /// <returns type="Number" />
179 // Get the Nth element in the matched element set OR
180 // Get the whole matched element set as a clean array
181 get: function( num
) {
183 /// Access a single matched element. num is used to access the
184 /// Nth element matched.
187 /// <returns type="Element" />
188 /// <param name="num" type="Number">
189 /// Access the element in the Nth position.
192 return num
== undefined ?
194 // Return a 'clean' array
195 Array
.prototype.slice
.call( this ) :
197 // Return just the object
201 // Take an array of elements and push it onto the stack
202 // (returning the new matched element set)
203 pushStack: function( elems
, name
, selector
) {
205 /// Set the jQuery object to an array of elements, while maintaining
209 /// <returns type="jQuery" />
210 /// <param name="elems" type="Elements">
211 /// An array of elements
214 // Build a new jQuery matched element set
215 var ret
= jQuery( elems
);
217 // Add the old object onto the stack (as a reference)
218 ret
.prevObject
= this;
220 ret
.context
= this.context
;
222 if ( name
=== "find" )
223 ret
.selector
= this.selector
+ (this.selector
? " " : "") + selector
;
225 ret
.selector
= this.selector
+ "." + name
+ "(" + selector
+ ")";
227 // Return the newly-formed element set
231 // Force the current matched set of elements to become
232 // the specified array of elements (destroying the stack in the process)
233 // You should use pushStack() in order to do this, but maintain the stack
234 setArray: function( elems
) {
236 /// Set the jQuery object to an array of elements. This operation is
237 /// completely destructive - be sure to use .pushStack() if you wish to maintain
238 /// the jQuery stack.
241 /// <returns type="jQuery" />
242 /// <param name="elems" type="Elements">
243 /// An array of elements
246 // Resetting the length to 0, then using the native Array push
247 // is a super-fast way to populate an object with array-like properties
249 Array
.prototype.push
.apply( this, elems
);
254 // Execute a callback for every element in the matched set.
255 // (You can seed the arguments with an array of args, but this is
256 // only used internally.)
257 each: function( callback
, args
) {
259 /// Execute a function within the context of every matched element.
260 /// This means that every time the passed-in function is executed
261 /// (which is once for every element matched) the 'this' keyword
262 /// points to the specific element.
263 /// Additionally, the function, when executed, is passed a single
264 /// argument representing the position of the element in the matched
268 /// <returns type="jQuery" />
269 /// <param name="callback" type="Function">
270 /// A function to execute
273 return jQuery
.each( this, callback
, args
);
276 // Determine the position of an element within
277 // the matched set of elements
278 index: function( elem
) {
280 /// Searches every matched element for the object and returns
281 /// the index of the element, if found, starting with zero.
282 /// Returns -1 if the object wasn't found.
285 /// <returns type="Number" />
286 /// <param name="elem" type="Element">
287 /// Object to search for
290 // Locate the position of the desired element
291 return jQuery
.inArray(
292 // If it receives a jQuery object, the first element is used
293 elem
&& elem
.jquery
? elem
[0] : elem
297 attr: function( name
, value
, type
) {
299 /// Set a single property to a computed value, on all matched elements.
300 /// Instead of a value, a function is provided, that computes the value.
301 /// Part of DOM/Attributes
303 /// <returns type="jQuery" />
304 /// <param name="name" type="String">
305 /// The name of the property to set.
307 /// <param name="value" type="Function">
308 /// A function returning the value to set.
313 // Look for the case where we're accessing a style value
314 if ( typeof name
=== "string" )
315 if ( value
=== undefined )
316 return this[0] && jQuery
[ type
|| "attr" ]( this[0], name
);
320 options
[ name
] = value
;
323 // Check to see if we're setting style values
324 return this.each(function(i
){
325 // Set all the styles
326 for ( name
in options
)
331 name
, jQuery
.prop( this, options
[ name
], type
, i
, name
)
336 css: function( key
, value
) {
338 /// Set a single style property to a value, on all matched elements.
339 /// If a number is provided, it is automatically converted into a pixel value.
342 /// <returns type="jQuery" />
343 /// <param name="key" type="String">
344 /// The name of the property to set.
346 /// <param name="value" type="String">
347 /// The value to set the property to.
350 // ignore negative width and height values
351 if ( (key
== 'width' || key
== 'height') && parseFloat(value
) < 0 )
353 return this.attr( key
, value
, "curCSS" );
356 text: function( text
) {
358 /// Set the text contents of all matched elements.
359 /// Similar to html(), but escapes HTML (replace "<" and ">" with their
361 /// Part of DOM/Attributes
363 /// <returns type="String" />
364 /// <param name="text" type="String">
365 /// The text value to set the contents of the element to.
368 if ( typeof text
!== "object" && text
!= null )
369 return this.empty().append( (this[0] && this[0].ownerDocument
|| document
).createTextNode( text
) );
373 jQuery
.each( text
|| this, function(){
374 jQuery
.each( this.childNodes
, function(){
375 if ( this.nodeType
!= 8 )
376 ret
+= this.nodeType
!= 1 ?
378 jQuery
.fn
.text( [ this ] );
385 wrapAll: function( html
) {
387 /// Wrap all matched elements with a structure of other elements.
388 /// This wrapping process is most useful for injecting additional
389 /// stucture into a document, without ruining the original semantic
390 /// qualities of a document.
391 /// This works by going through the first element
392 /// provided and finding the deepest ancestor element within its
393 /// structure - it is that element that will en-wrap everything else.
394 /// This does not work with elements that contain text. Any necessary text
395 /// must be added after the wrapping is done.
396 /// Part of DOM/Manipulation
398 /// <returns type="jQuery" />
399 /// <param name="html" type="Element">
400 /// A DOM element that will be wrapped around the target.
404 // The elements to wrap the target around
405 var wrap
= jQuery( html
, this[0].ownerDocument
).clone();
407 if ( this[0].parentNode
)
408 wrap
.insertBefore( this[0] );
413 while ( elem
.firstChild
)
414 elem
= elem
.firstChild
;
423 wrapInner: function( html
) {
425 /// Wraps the inner child contents of each matched elemenht (including text nodes) with an HTML structure.
427 /// <param name="html" type="String">
428 /// A string of HTML or a DOM element that will be wrapped around the target contents.
430 /// <returns type="jQuery" />
432 return this.each(function(){
433 jQuery( this ).contents().wrapAll( html
);
437 wrap: function( html
) {
439 /// Wrap all matched elements with a structure of other elements.
440 /// This wrapping process is most useful for injecting additional
441 /// stucture into a document, without ruining the original semantic
442 /// qualities of a document.
443 /// This works by going through the first element
444 /// provided and finding the deepest ancestor element within its
445 /// structure - it is that element that will en-wrap everything else.
446 /// This does not work with elements that contain text. Any necessary text
447 /// must be added after the wrapping is done.
448 /// Part of DOM/Manipulation
450 /// <returns type="jQuery" />
451 /// <param name="html" type="Element">
452 /// A DOM element that will be wrapped around the target.
455 return this.each(function(){
456 jQuery( this ).wrapAll( html
);
462 /// Append content to the inside of every matched element.
463 /// This operation is similar to doing an appendChild to all the
464 /// specified elements, adding them into the document.
465 /// Part of DOM/Manipulation
467 /// <returns type="jQuery" />
468 /// <param name="content" type="Content">
469 /// Content to append to the target
472 return this.domManip(arguments
, true, function(elem
){
473 if (this.nodeType
== 1)
474 this.appendChild( elem
);
478 prepend: function() {
480 /// Prepend content to the inside of every matched element.
481 /// This operation is the best way to insert elements
482 /// inside, at the beginning, of all matched elements.
483 /// Part of DOM/Manipulation
485 /// <returns type="jQuery" />
486 /// <param name="" type="Content">
487 /// Content to prepend to the target.
490 return this.domManip(arguments
, true, function(elem
){
491 if (this.nodeType
== 1)
492 this.insertBefore( elem
, this.firstChild
);
498 /// Insert content before each of the matched elements.
499 /// Part of DOM/Manipulation
501 /// <returns type="jQuery" />
502 /// <param name="" type="Content">
503 /// Content to insert before each target.
506 return this.domManip(arguments
, false, function(elem
){
507 this.parentNode
.insertBefore( elem
, this );
513 /// Insert content after each of the matched elements.
514 /// Part of DOM/Manipulation
516 /// <returns type="jQuery" />
517 /// <param name="" type="Content">
518 /// Content to insert after each target.
521 return this.domManip(arguments
, false, function(elem
){
522 this.parentNode
.insertBefore( elem
, this.nextSibling
);
528 /// End the most recent 'destructive' operation, reverting the list of matched elements
529 /// back to its previous state. After an end operation, the list of matched elements will
530 /// revert to the last state of matched elements.
531 /// If there was no destructive operation before, an empty set is returned.
532 /// Part of DOM/Traversing
534 /// <returns type="jQuery" />
536 return this.prevObject
|| jQuery( [] );
539 // For internal use only.
540 // Behaves like an Array's method, not like a jQuery method.
545 find: function( selector
) {
547 /// Searches for all elements that match the specified expression.
548 /// This method is a good way to find additional descendant
549 /// elements with which to process.
550 /// All searching is done using a jQuery expression. The expression can be
551 /// written using CSS 1-3 Selector syntax, or basic XPath.
552 /// Part of DOM/Traversing
554 /// <returns type="jQuery" />
555 /// <param name="selector" type="String">
556 /// An expression to search with.
558 /// <returns type="jQuery" />
560 if ( this.length
=== 1 ) {
561 var ret
= this.pushStack( [], "find", selector
);
563 jQuery
.find( selector
, this[0], ret
);
566 return this.pushStack( jQuery
.unique(jQuery
.map(this, function(elem
){
567 return jQuery
.find( selector
, elem
);
568 })), "find", selector
);
572 clone: function( events
) {
574 /// Clone matched DOM Elements and select the clones.
575 /// This is useful for moving copies of the elements to another
576 /// location in the DOM.
577 /// Part of DOM/Manipulation
579 /// <returns type="jQuery" />
580 /// <param name="deep" type="Boolean" optional="true">
581 /// (Optional) Set to false if you don't want to clone all descendant nodes, in addition to the element itself.
585 var ret
= this.map(function(){
586 if ( !jQuery
.support
.noCloneEvent
&& !jQuery
.isXMLDoc(this) ) {
587 // IE copies events bound via attachEvent when
588 // using cloneNode. Calling detachEvent on the
589 // clone will also remove the events from the orignal
590 // In order to get around this, we use innerHTML.
591 // Unfortunately, this means some modifications to
592 // attributes in IE that are actually only stored
593 // as properties will not be copied (such as the
594 // the name attribute on an input).
595 var html
= this.outerHTML
;
597 var div
= this.ownerDocument
.createElement("div");
598 div
.appendChild( this.cloneNode(true) );
599 html
= div
.innerHTML
;
602 return jQuery
.clean([html
.replace(/ jQuery
\d
+="(?:\d+|null)"/g, "").replace(/^\s*/
, "")])[0];
604 return this.cloneNode(true);
607 // Copy the events from the original to the clone
608 if ( events
=== true ) {
609 var orig
= this.find("*").andSelf(), i
= 0;
611 ret
.find("*").andSelf().each(function(){
612 if ( this.nodeName
!== orig
[i
].nodeName
)
615 var events
= jQuery
.data( orig
[i
], "events" );
617 for ( var type
in events
) {
618 for ( var handler
in events
[ type
] ) {
619 jQuery
.event
.add( this, type
, events
[ type
][ handler
], events
[ type
][ handler
].data
);
627 // Return the cloned set
631 filter: function( selector
) {
633 /// Removes all elements from the set of matched elements that do not
634 /// pass the specified filter. This method is used to narrow down
635 /// the results of a search.
637 /// Part of DOM/Traversing
639 /// <returns type="jQuery" />
640 /// <param name="selector" type="Function">
641 /// A function to use for filtering
643 /// <returns type="jQuery" />
645 return this.pushStack(
646 jQuery
.isFunction( selector
) &&
647 jQuery
.grep(this, function(elem
, i
){
648 return selector
.call( elem
, i
);
651 jQuery
.multiFilter( selector
, jQuery
.grep(this, function(elem
){
652 return elem
.nodeType
=== 1;
653 }) ), "filter", selector
);
656 closest: function( selector
) {
658 /// Get a set of elements containing the closest parent element that matches the specified selector, the starting element included.
660 /// <returns type="jQuery" />
661 /// <param name="selector" type="Function">
662 /// An expression to filter the elements with.
664 /// <returns type="jQuery" />
666 var pos
= jQuery
.expr
.match
.POS
.test( selector
) ? jQuery(selector
) : null,
669 return this.map(function(){
671 while ( cur
&& cur
.ownerDocument
) {
672 if ( pos
? pos
.index(cur
) > -1 : jQuery(cur
).is(selector
) ) {
673 jQuery
.data(cur
, "closest", closer
);
676 cur
= cur
.parentNode
;
682 not: function( selector
) {
684 /// Removes any elements inside the array of elements from the set
685 /// of matched elements. This method is used to remove one or more
686 /// elements from a jQuery object.
687 /// Part of DOM/Traversing
689 /// <param name="selector" type="jQuery">
690 /// A set of elements to remove from the jQuery set of matched elements.
692 /// <returns type="jQuery" />
694 if ( typeof selector
=== "string" )
695 // test special case where just one selector is passed in
696 if ( isSimple
.test( selector
) )
697 return this.pushStack( jQuery
.multiFilter( selector
, this, true ), "not", selector
);
699 selector
= jQuery
.multiFilter( selector
, this );
701 var isArrayLike
= selector
.length
&& selector
[selector
.length
- 1] !== undefined && !selector
.nodeType
;
702 return this.filter(function() {
703 return isArrayLike
? jQuery
.inArray( this, selector
) < 0 : this != selector
;
707 add: function( selector
) {
709 /// Adds one or more Elements to the set of matched elements.
710 /// Part of DOM/Traversing
712 /// <param name="elements" type="Element">
713 /// One or more Elements to add
715 /// <returns type="jQuery" />
717 return this.pushStack( jQuery
.unique( jQuery
.merge(
719 typeof selector
=== "string" ?
721 jQuery
.makeArray( selector
)
725 is: function( selector
) {
727 /// Checks the current selection against an expression and returns true,
728 /// if at least one element of the selection fits the given expression.
729 /// Does return false, if no element fits or the expression is not valid.
730 /// filter(String) is used internally, therefore all rules that apply there
732 /// Part of DOM/Traversing
734 /// <returns type="Boolean" />
735 /// <param name="expr" type="String">
736 /// The expression with which to filter
739 return !!selector
&& jQuery
.multiFilter( selector
, this ).length
> 0;
742 hasClass: function( selector
) {
744 /// Checks the current selection against a class and returns whether at least one selection has a given class.
746 /// <param name="selector" type="String">The class to check against</param>
747 /// <returns type="Boolean">True if at least one element in the selection has the class, otherwise false.</returns>
749 return !!selector
&& this.is( "." + selector
);
752 val: function( value
) {
754 /// Set the value of every matched element.
755 /// Part of DOM/Attributes
757 /// <returns type="jQuery" />
758 /// <param name="val" type="String">
759 /// Set the property to the specified value.
762 if ( value
=== undefined ) {
766 if( jQuery
.nodeName( elem
, 'option' ) )
767 return (elem
.attributes
.value
|| {}).specified
? elem
.value
: elem
.text
;
769 // We need to handle select boxes special
770 if ( jQuery
.nodeName( elem
, "select" ) ) {
771 var index
= elem
.selectedIndex
,
773 options
= elem
.options
,
774 one
= elem
.type
== "select-one";
776 // Nothing was selected
780 // Loop through all the selected options
781 for ( var i
= one
? index
: 0, max
= one
? index
+ 1 : options
.length
; i
< max
; i
++ ) {
782 var option
= options
[ i
];
784 if ( option
.selected
) {
785 // Get the specifc value for the option
786 value
= jQuery(option
).val();
788 // We don't need an array for one selects
792 // Multi-Selects return an array
793 values
.push( value
);
800 // Everything else, we just grab the value
801 return (elem
.value
|| "").replace(/\r/g, "");
808 if ( typeof value
=== "number" )
811 return this.each(function(){
812 if ( this.nodeType
!= 1 )
815 if ( jQuery
.isArray(value
) && /radio|checkbox/.test( this.type
) )
816 this.checked
= (jQuery
.inArray(this.value
, value
) >= 0 ||
817 jQuery
.inArray(this.name
, value
) >= 0);
819 else if ( jQuery
.nodeName( this, "select" ) ) {
820 var values
= jQuery
.makeArray(value
);
822 jQuery( "option", this ).each(function(){
823 this.selected
= (jQuery
.inArray( this.value
, values
) >= 0 ||
824 jQuery
.inArray( this.text
, values
) >= 0);
827 if ( !values
.length
)
828 this.selectedIndex
= -1;
835 html: function( value
) {
837 /// Set the html contents of every matched element.
838 /// This property is not available on XML documents.
839 /// Part of DOM/Attributes
841 /// <returns type="jQuery" />
842 /// <param name="val" type="String">
843 /// Set the html contents to the specified value.
846 return value
=== undefined ?
848 this[0].innerHTML
.replace(/ jQuery
\d
+="(?:\d+|null)"/g
, "") :
850 this.empty().append( value
);
853 replaceWith: function( value
) {
855 /// Replaces all matched element with the specified HTML or DOM elements.
857 /// <param name="value" type="String">
858 /// The content with which to replace the matched elements.
860 /// <returns type="jQuery">The element that was just replaced.</returns>
862 return this.after( value
).remove();
867 /// Reduce the set of matched elements to a single element.
868 /// The position of the element in the set of matched elements
869 /// starts at 0 and goes to length - 1.
872 /// <returns type="jQuery" />
873 /// <param name="num" type="Number">
874 /// pos The index of the element that you wish to limit to.
877 return this.slice( i
, +i
+ 1 );
882 /// Selects a subset of the matched elements. Behaves exactly like the built-in Array slice method.
884 /// <param name="start" type="Number" integer="true">Where to start the subset (0-based).</param>
885 /// <param name="end" optional="true" type="Number" integer="true">Where to end the subset (not including the end element itself).
886 /// If omitted, ends at the end of the selection</param>
887 /// <returns type="jQuery">The sliced elements</returns>
889 return this.pushStack( Array
.prototype.slice
.apply( this, arguments
),
890 "slice", Array
.prototype.slice
.call(arguments
).join(",") );
893 map: function( callback
) {
895 /// This member is internal.
898 /// <returns type="jQuery" />
900 return this.pushStack( jQuery
.map(this, function(elem
, i
){
901 return callback
.call( elem
, i
, elem
);
905 andSelf: function() {
907 /// Adds the previous selection to the current selection.
909 /// <returns type="jQuery" />
911 return this.add( this.prevObject
);
914 domManip: function( args
, table
, callback
) {
915 /// <param name="args" type="Array">
918 /// <param name="table" type="Boolean">
919 /// Insert TBODY in TABLEs if one is not found.
921 /// <param name="dir" type="Number">
922 /// If dir<0, process args in reverse order.
924 /// <param name="fn" type="Function">
925 /// The function doing the DOM manipulation.
927 /// <returns type="jQuery" />
933 var fragment
= (this[0].ownerDocument
|| this[0]).createDocumentFragment(),
934 scripts
= jQuery
.clean( args
, (this[0].ownerDocument
|| this[0]), fragment
),
935 first
= fragment
.firstChild
;
938 for ( var i
= 0, l
= this.length
; i
< l
; i
++ )
939 callback
.call( root(this[i
], first
), this.length
> 1 || i
> 0 ?
940 fragment
.cloneNode(true) : fragment
);
943 jQuery
.each( scripts
, evalScript
);
948 function root( elem
, cur
) {
949 return table
&& jQuery
.nodeName(elem
, "table") && jQuery
.nodeName(cur
, "tr") ?
950 (elem
.getElementsByTagName("tbody")[0] ||
951 elem
.appendChild(elem
.ownerDocument
.createElement("tbody"))) :
957 // Give the init function the jQuery prototype for later instantiation
958 jQuery
.fn
.init
.prototype = jQuery
.fn
;
960 function evalScript( i
, elem
) {
962 /// This method is internal.
974 jQuery
.globalEval( elem
.text
|| elem
.textContent
|| elem
.innerHTML
|| "" );
976 if ( elem
.parentNode
)
977 elem
.parentNode
.removeChild( elem
);
982 /// Gets the current date.
984 /// <returns type="Date">The current date.</returns>
988 jQuery
.extend
= jQuery
.fn
.extend = function() {
990 /// Extend one object with one or more others, returning the original,
991 /// modified, object. This is a great utility for simple inheritance.
992 /// jQuery.extend(settings, options);
993 /// var settings = jQuery.extend({}, defaults, options);
994 /// Part of JavaScript
996 /// <param name="target" type="Object">
997 /// The object to extend
999 /// <param name="prop1" type="Object">
1000 /// The object that will be merged into the first.
1002 /// <param name="propN" type="Object" optional="true" parameterArray="true">
1003 /// (optional) More objects to merge into the first
1005 /// <returns type="Object" />
1007 // copy reference to target object
1008 var target
= arguments
[0] || {}, i
= 1, length
= arguments
.length
, deep
= false, options
;
1010 // Handle a deep copy situation
1011 if ( typeof target
=== "boolean" ) {
1013 target
= arguments
[1] || {};
1014 // skip the boolean and the target
1018 // Handle case when target is a string or something (possible in deep copy)
1019 if ( typeof target
!== "object" && !jQuery
.isFunction(target
) )
1022 // extend jQuery itself if only one argument is passed
1023 if ( length
== i
) {
1028 for ( ; i
< length
; i
++ )
1029 // Only deal with non-null/undefined values
1030 if ( (options
= arguments
[ i
]) != null )
1031 // Extend the base object
1032 for ( var name
in options
) {
1033 var src
= target
[ name
], copy
= options
[ name
];
1035 // Prevent never-ending loop
1036 if ( target
=== copy
)
1039 // Recurse if we're merging object values
1040 if ( deep
&& copy
&& typeof copy
=== "object" && !copy
.nodeType
)
1041 target
[ name
] = jQuery
.extend( deep
,
1042 // Never move original objects, clone them
1043 src
|| ( copy
.length
!= null ? [ ] : { } )
1046 // Don't bring in undefined values
1047 else if ( copy
!== undefined )
1048 target
[ name
] = copy
;
1052 // Return the modified object
1056 // exclude the following css properties to add px
1057 var exclude
= /z-?index|font-?weight|opacity|zoom|line-?height/i,
1058 // cache defaultView
1059 defaultView
= document
.defaultView
|| {},
1060 toString
= Object
.prototype.toString
;
1063 noConflict: function( deep
) {
1065 /// Run this function to give control of the $ variable back
1066 /// to whichever library first implemented it. This helps to make
1067 /// sure that jQuery doesn't conflict with the $ object
1068 /// of other libraries.
1069 /// By using this function, you will only be able to access jQuery
1070 /// using the 'jQuery' variable. For example, where you used to do
1071 /// $("div p"), you now must do jQuery("div p").
1074 /// <returns type="undefined" />
1079 window
.jQuery
= _jQuery
;
1084 // See test/unit/core.js for details concerning isFunction.
1085 // Since version 1.3, DOM methods and functions like alert
1086 // aren't supported. They return false on IE (#2968).
1087 isFunction: function( obj
) {
1089 /// Determines if the parameter passed is a function.
1091 /// <param name="obj" type="Object">The object to check</param>
1092 /// <returns type="Boolean">True if the parameter is a function; otherwise false.</returns>
1094 return toString
.call(obj
) === "[object Function]";
1097 isArray: function(obj
) {
1099 /// Determine if the parameter passed is an array.
1101 /// <param name="obj" type="Object">Object to test whether or not it is an array.</param>
1102 /// <returns type="Boolean">True if the parameter is a function; otherwise false.</returns>
1104 return toString
.call(obj
) === "[object Array]";
1107 // check if an element is in a (or is an) XML document
1108 isXMLDoc: function( elem
) {
1110 /// Determines if the parameter passed is an XML document.
1112 /// <param name="elem" type="Object">The object to test</param>
1113 /// <returns type="Boolean">True if the parameter is an XML document; otherwise false.</returns>
1115 return elem
.nodeType
=== 9 && elem
.documentElement
.nodeName
!== "HTML" ||
1116 !!elem
.ownerDocument
&& jQuery
.isXMLDoc(elem
.ownerDocument
);
1119 // Evalulates a script in a global context
1120 globalEval: function( data
) {
1122 /// Internally evaluates a script in a global context.
1126 if ( data
&& /\S/.test(data
) ) {
1127 // Inspired by code by Andrea Giammarchi
1128 // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
1129 var head
= document
.getElementsByTagName("head")[0] || document
.documentElement
,
1130 script
= document
.createElement("script");
1132 script
.type
= "text/javascript";
1133 if ( jQuery
.support
.scriptEval
)
1134 script
.appendChild( document
.createTextNode( data
) );
1138 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
1139 // This arises when a base node is used (#2709).
1140 head
.insertBefore( script
, head
.firstChild
);
1141 head
.removeChild( script
);
1145 nodeName: function( elem
, name
) {
1147 /// Checks whether the specified element has the specified DOM node name.
1149 /// <param name="elem" type="Element">The element to examine</param>
1150 /// <param name="name" type="String">The node name to check</param>
1151 /// <returns type="Boolean">True if the specified node name matches the node's DOM node name; otherwise false</returns>
1153 return elem
.nodeName
&& elem
.nodeName
.toUpperCase() == name
.toUpperCase();
1156 // args is for internal usage only
1157 each: function( object
, callback
, args
) {
1159 /// A generic iterator function, which can be used to seemlessly
1160 /// iterate over both objects and arrays. This function is not the same
1161 /// as $().each() - which is used to iterate, exclusively, over a jQuery
1162 /// object. This function can be used to iterate over anything.
1163 /// The callback has two arguments:the key (objects) or index (arrays) as first
1164 /// the first, and the value as the second.
1165 /// Part of JavaScript
1167 /// <param name="obj" type="Object">
1168 /// The object, or array, to iterate over.
1170 /// <param name="fn" type="Function">
1171 /// The function that will be executed on every object.
1173 /// <returns type="Object" />
1175 var name
, i
= 0, length
= object
.length
;
1178 if ( length
=== undefined ) {
1179 for ( name
in object
)
1180 if ( callback
.apply( object
[ name
], args
) === false )
1183 for ( ; i
< length
; )
1184 if ( callback
.apply( object
[ i
++ ], args
) === false )
1187 // A special, fast, case for the most common use of each
1189 if ( length
=== undefined ) {
1190 for ( name
in object
)
1191 if ( callback
.call( object
[ name
], name
, object
[ name
] ) === false )
1194 for ( var value
= object
[0];
1195 i
< length
&& callback
.call( value
, i
, value
) !== false; value
= object
[++i
] ){}
1201 prop: function( elem
, value
, type
, i
, name
) {
1203 /// This method is internal.
1206 // This member is not documented within the jQuery API: http://docs.jquery.com/action/edit/Internals/jQuery.prop
1208 // Handle executable functions
1209 if ( jQuery
.isFunction( value
) )
1210 value
= value
.call( elem
, i
);
1212 // Handle passing in a number to a CSS property
1213 return typeof value
=== "number" && type
== "curCSS" && !exclude
.test( name
) ?
1219 // internal only, use addClass("class")
1220 add: function( elem
, classNames
) {
1222 /// Internal use only; use addClass('class')
1226 jQuery
.each((classNames
|| "").split(/\s+/), function(i
, className
){
1227 if ( elem
.nodeType
== 1 && !jQuery
.className
.has( elem
.className
, className
) )
1228 elem
.className
+= (elem
.className
? " " : "") + className
;
1232 // internal only, use removeClass("class")
1233 remove: function( elem
, classNames
) {
1235 /// Internal use only; use removeClass('class')
1239 if (elem
.nodeType
== 1)
1240 elem
.className
= classNames
!== undefined ?
1241 jQuery
.grep(elem
.className
.split(/\s+/), function(className
){
1242 return !jQuery
.className
.has( classNames
, className
);
1247 // internal only, use hasClass("class")
1248 has: function( elem
, className
) {
1250 /// Internal use only; use hasClass('class')
1254 return elem
&& jQuery
.inArray(className
, (elem
.className
|| elem
).toString().split(/\s+/)) > -1;
1258 // A method for quickly swapping in/out CSS properties to get correct calculations
1259 swap: function( elem
, options
, callback
) {
1261 /// Swap in/out style options.
1265 // Remember the old values, and insert the new ones
1266 for ( var name
in options
) {
1267 old
[ name
] = elem
.style
[ name
];
1268 elem
.style
[ name
] = options
[ name
];
1271 callback
.call( elem
);
1273 // Revert the old values
1274 for ( var name
in options
)
1275 elem
.style
[ name
] = old
[ name
];
1278 css: function( elem
, name
, force
, extra
) {
1280 /// This method is internal only.
1283 // This method is undocumented in jQuery API: http://docs.jquery.com/action/edit/Internals/jQuery.css
1285 if ( name
== "width" || name
== "height" ) {
1286 var val
, props
= { position
: "absolute", visibility
: "hidden", display
:"block" }, which
= name
== "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ];
1289 val
= name
== "width" ? elem
.offsetWidth
: elem
.offsetHeight
;
1291 if ( extra
=== "border" )
1294 jQuery
.each( which
, function() {
1296 val
-= parseFloat(jQuery
.curCSS( elem
, "padding" + this, true)) || 0;
1297 if ( extra
=== "margin" )
1298 val
+= parseFloat(jQuery
.curCSS( elem
, "margin" + this, true)) || 0;
1300 val
-= parseFloat(jQuery
.curCSS( elem
, "border" + this + "Width", true)) || 0;
1304 if ( elem
.offsetWidth
!== 0 )
1307 jQuery
.swap( elem
, props
, getWH
);
1309 return Math
.max(0, Math
.round(val
));
1312 return jQuery
.curCSS( elem
, name
, force
);
1315 curCSS: function( elem
, name
, force
) {
1317 /// This method is internal only.
1320 // This method is undocumented in jQuery API: http://docs.jquery.com/action/edit/Internals/jQuery.curCSS
1322 var ret
, style
= elem
.style
;
1324 // We need to handle opacity special in IE
1325 if ( name
== "opacity" && !jQuery
.support
.opacity
) {
1326 ret
= jQuery
.attr( style
, "opacity" );
1333 // Make sure we're using the right name for getting the float value
1334 if ( name
.match( /float/i ) )
1337 if ( !force
&& style
&& style
[ name
] )
1338 ret
= style
[ name
];
1340 else if ( defaultView
.getComputedStyle
) {
1342 // Only "float" is needed here
1343 if ( name
.match( /float/i ) )
1346 name
= name
.replace( /([A-Z])/g, "-$1" ).toLowerCase();
1348 var computedStyle
= defaultView
.getComputedStyle( elem
, null );
1350 if ( computedStyle
)
1351 ret
= computedStyle
.getPropertyValue( name
);
1353 // We should always get a number back from opacity
1354 if ( name
== "opacity" && ret
== "" )
1357 } else if ( elem
.currentStyle
) {
1358 var camelCase
= name
.replace(/\-(\w)/g, function(all
, letter
){
1359 return letter
.toUpperCase();
1362 ret
= elem
.currentStyle
[ name
] || elem
.currentStyle
[ camelCase
];
1364 // From the awesome hack by Dean Edwards
1365 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
1367 // If we're not dealing with a regular pixel number
1368 // but a number that has a weird ending, we need to convert it to pixels
1369 if ( !/^\d+(px)?$/i.test( ret
) && /^\d/.test( ret
) ) {
1370 // Remember the original values
1371 var left
= style
.left
, rsLeft
= elem
.runtimeStyle
.left
;
1373 // Put in the new values to get a computed value out
1374 elem
.runtimeStyle
.left
= elem
.currentStyle
.left
;
1375 style
.left
= ret
|| 0;
1376 ret
= style
.pixelLeft
+ "px";
1378 // Revert the changed values
1380 elem
.runtimeStyle
.left
= rsLeft
;
1387 clean: function( elems
, context
, fragment
) {
1389 /// This method is internal only.
1392 // This method is undocumented in the jQuery API: http://docs.jquery.com/action/edit/Internals/jQuery.clean
1395 context
= context
|| document
;
1397 // !context.createElement fails in IE with an error but returns typeof 'object'
1398 if ( typeof context
.createElement
=== "undefined" )
1399 context
= context
.ownerDocument
|| context
[0] && context
[0].ownerDocument
|| document
;
1401 // If a single string is passed in and it's a single tag
1402 // just do a createElement and skip the rest
1403 if ( !fragment
&& elems
.length
=== 1 && typeof elems
[0] === "string" ) {
1404 var match
= /^<(\w+)\s*\/?>$/.exec(elems
[0]);
1406 return [ context
.createElement( match
[1] ) ];
1409 var ret
= [], scripts
= [], div
= context
.createElement("div");
1411 jQuery
.each(elems
, function(i
, elem
){
1412 if ( typeof elem
=== "number" )
1418 // Convert html string into DOM nodes
1419 if ( typeof elem
=== "string" ) {
1420 // Fix "XHTML"-style tags in all browsers
1421 elem
= elem
.replace(/(<(\w+)[^>]*?)\/>/g, function(all
, front
, tag
){
1422 return tag
.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
1424 front
+ "></" + tag
+ ">";
1427 // Trim whitespace, otherwise indexOf won't work as expected
1428 var tags
= elem
.replace(/^\s+/, "").substring(0, 10).toLowerCase();
1431 // option or optgroup
1432 !tags
.indexOf("<opt") &&
1433 [ 1, "<select multiple='multiple'>", "</select>" ] ||
1435 !tags
.indexOf("<leg") &&
1436 [ 1, "<fieldset>", "</fieldset>" ] ||
1438 tags
.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
1439 [ 1, "<table>", "</table>" ] ||
1441 !tags
.indexOf("<tr") &&
1442 [ 2, "<table><tbody>", "</tbody></table>" ] ||
1444 // <thead> matched above
1445 (!tags
.indexOf("<td") || !tags
.indexOf("<th")) &&
1446 [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
1448 !tags
.indexOf("<col") &&
1449 [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
1451 // IE can't serialize <link> and <script> tags normally
1452 !jQuery
.support
.htmlSerialize
&&
1453 [ 1, "div<div>", "</div>" ] ||
1457 // Go to html and back, then peel off extra wrappers
1458 div
.innerHTML
= wrap
[1] + elem
+ wrap
[2];
1460 // Move to the right depth
1462 div
= div
.lastChild
;
1464 // Remove IE's autoinserted <tbody> from table fragments
1465 if ( !jQuery
.support
.tbody
) {
1467 // String was a <table>, *may* have spurious <tbody>
1468 var hasBody
= /<tbody/i.test(elem
),
1469 tbody
= !tags
.indexOf("<table") && !hasBody
?
1470 div
.firstChild
&& div
.firstChild
.childNodes
:
1472 // String was a bare <thead> or <tfoot>
1473 wrap
[1] == "<table>" && !hasBody
?
1477 for ( var j
= tbody
.length
- 1; j
>= 0 ; --j
)
1478 if ( jQuery
.nodeName( tbody
[ j
], "tbody" ) && !tbody
[ j
].childNodes
.length
)
1479 tbody
[ j
].parentNode
.removeChild( tbody
[ j
] );
1483 // IE completely kills leading whitespace when innerHTML is used
1484 if ( !jQuery
.support
.leadingWhitespace
&& /^\s/.test( elem
) )
1485 div
.insertBefore( context
.createTextNode( elem
.match(/^\s*/)[0] ), div
.firstChild
);
1487 elem
= jQuery
.makeArray( div
.childNodes
);
1490 if ( elem
.nodeType
)
1493 ret
= jQuery
.merge( ret
, elem
);
1498 for ( var i
= 0; ret
[i
]; i
++ ) {
1499 if ( jQuery
.nodeName( ret
[i
], "script" ) && (!ret
[i
].type
|| ret
[i
].type
.toLowerCase() === "text/javascript") ) {
1500 scripts
.push( ret
[i
].parentNode
? ret
[i
].parentNode
.removeChild( ret
[i
] ) : ret
[i
] );
1502 if ( ret
[i
].nodeType
=== 1 )
1503 ret
.splice
.apply( ret
, [i
+ 1, 0].concat(jQuery
.makeArray(ret
[i
].getElementsByTagName("script"))) );
1504 fragment
.appendChild( ret
[i
] );
1514 attr: function( elem
, name
, value
) {
1516 /// This method is internal.
1520 // don't set attributes on text and comment nodes
1521 if (!elem
|| elem
.nodeType
== 3 || elem
.nodeType
== 8)
1524 var notxml
= !jQuery
.isXMLDoc( elem
),
1525 // Whether we are setting (or getting)
1526 set = value
!== undefined;
1528 // Try to normalize/fix the name
1529 name
= notxml
&& jQuery
.props
[ name
] || name
;
1531 // Only do all the following if this is a node (faster for style)
1532 // IE elem.getAttribute passes even for style
1533 if ( elem
.tagName
) {
1535 // These attributes require special treatment
1536 var special
= /href|src|style/.test( name
);
1538 // Safari mis-reports the default selected property of a hidden option
1539 // Accessing the parent's selectedIndex property fixes it
1540 if ( name
== "selected" && elem
.parentNode
)
1541 elem
.parentNode
.selectedIndex
;
1543 // If applicable, access the attribute via the DOM 0 way
1544 if ( name
in elem
&& notxml
&& !special
) {
1546 // We can't allow the type property to be changed (since it causes problems in IE)
1547 if ( name
== "type" && jQuery
.nodeName( elem
, "input" ) && elem
.parentNode
)
1548 throw "type property can't be changed";
1550 elem
[ name
] = value
;
1553 // browsers index elements by id/name on forms, give priority to attributes.
1554 if( jQuery
.nodeName( elem
, "form" ) && elem
.getAttributeNode(name
) )
1555 return elem
.getAttributeNode( name
).nodeValue
;
1557 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
1558 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
1559 if ( name
== "tabIndex" ) {
1560 var attributeNode
= elem
.getAttributeNode( "tabIndex" );
1561 return attributeNode
&& attributeNode
.specified
1562 ? attributeNode
.value
1563 : elem
.nodeName
.match(/(button|input|object|select|textarea)/i)
1565 : elem
.nodeName
.match(/^(a|area)$/i) && elem
.href
1570 return elem
[ name
];
1573 if ( !jQuery
.support
.style
&& notxml
&& name
== "style" )
1574 return jQuery
.attr( elem
.style
, "cssText", value
);
1577 // convert the value to a string (all browsers do this but IE) see #1070
1578 elem
.setAttribute( name
, "" + value
);
1580 var attr
= !jQuery
.support
.hrefNormalized
&& notxml
&& special
1581 // Some attributes require a special call on IE
1582 ? elem
.getAttribute( name
, 2 )
1583 : elem
.getAttribute( name
);
1585 // Non-existent attributes return null, we normalize to undefined
1586 return attr
=== null ? undefined : attr
;
1589 // elem is actually elem.style ... set the style
1591 // IE uses filters for opacity
1592 if ( !jQuery
.support
.opacity
&& name
== "opacity" ) {
1594 // IE has trouble with opacity if it does not have layout
1595 // Force it by setting the zoom level
1598 // Set the alpha filter to set the opacity
1599 elem
.filter
= (elem
.filter
|| "").replace( /alpha\([^)]*\)/, "" ) +
1600 (parseInt( value
) + '' == "NaN" ? "" : "alpha(opacity=" + value
* 100 + ")");
1603 return elem
.filter
&& elem
.filter
.indexOf("opacity=") >= 0 ?
1604 (parseFloat( elem
.filter
.match(/opacity=([^)]*)/)[1] ) / 100) + '':
1608 name
= name
.replace(/-([a-z])/ig, function(all
, letter
){
1609 return letter
.toUpperCase();
1613 elem
[ name
] = value
;
1615 return elem
[ name
];
1618 trim: function( text
) {
1620 /// Remove the whitespace from the beginning and end of a string.
1621 /// Part of JavaScript
1623 /// <returns type="String" />
1624 /// <param name="text" type="String">
1625 /// The string to trim.
1628 return (text
|| "").replace( /^\s+|\s+$/g, "" );
1631 makeArray: function( array
) {
1633 /// Turns anything into a true array. This is an internal method.
1635 /// <param name="array" type="Object">Anything to turn into an actual Array</param>
1636 /// <returns type="Array" />
1641 if( array
!= null ){
1642 var i
= array
.length
;
1643 // The window, strings (and functions) also have 'length'
1644 if( i
== null || typeof array
=== "string" || jQuery
.isFunction(array
) || array
.setInterval
)
1648 ret
[--i
] = array
[i
];
1654 inArray: function( elem
, array
) {
1656 /// Determines the index of the first parameter in the array.
1658 /// <param name="elem">The value to see if it exists in the array.</param>
1659 /// <param name="array" type="Array">The array to look through for the value</param>
1660 /// <returns type="Number" integer="true">The 0-based index of the item if it was found, otherwise -1.</returns>
1662 for ( var i
= 0, length
= array
.length
; i
< length
; i
++ )
1663 // Use === because on IE, window == document
1664 if ( array
[ i
] === elem
)
1670 merge: function( first
, second
) {
1672 /// Merge two arrays together, removing all duplicates.
1673 /// The new array is: All the results from the first array, followed
1674 /// by the unique results from the second array.
1675 /// Part of JavaScript
1677 /// <returns type="Array" />
1678 /// <param name="first" type="Array">
1679 /// The first array to merge.
1681 /// <param name="second" type="Array">
1682 /// The second array to merge.
1685 // We have to loop this way because IE & Opera overwrite the length
1686 // expando of getElementsByTagName
1687 var i
= 0, elem
, pos
= first
.length
;
1688 // Also, we need to make sure that the correct elements are being returned
1689 // (IE returns comment nodes in a '*' query)
1690 if ( !jQuery
.support
.getAll
) {
1691 while ( (elem
= second
[ i
++ ]) != null )
1692 if ( elem
.nodeType
!= 8 )
1693 first
[ pos
++ ] = elem
;
1696 while ( (elem
= second
[ i
++ ]) != null )
1697 first
[ pos
++ ] = elem
;
1702 unique: function( array
) {
1704 /// Removes all duplicate elements from an array of elements.
1706 /// <param name="array" type="Array<Element>">The array to translate</param>
1707 /// <returns type="Array<Element>">The array after translation.</returns>
1709 var ret
= [], done
= {};
1713 for ( var i
= 0, length
= array
.length
; i
< length
; i
++ ) {
1714 var id
= jQuery
.data( array
[ i
] );
1716 if ( !done
[ id
] ) {
1718 ret
.push( array
[ i
] );
1729 grep: function( elems
, callback
, inv
) {
1731 /// Filter items out of an array, by using a filter function.
1732 /// The specified function will be passed two arguments: The
1733 /// current array item and the index of the item in the array. The
1734 /// function must return 'true' to keep the item in the array,
1735 /// false to remove it.
1737 /// Part of JavaScript
1739 /// <returns type="Array" />
1740 /// <param name="elems" type="Array">
1741 /// array The Array to find items in.
1743 /// <param name="fn" type="Function">
1744 /// The function to process each item against.
1746 /// <param name="inv" type="Boolean">
1747 /// Invert the selection - select the opposite of the function.
1752 // Go through the array, only saving the items
1753 // that pass the validator function
1754 for ( var i
= 0, length
= elems
.length
; i
< length
; i
++ )
1755 if ( !inv
!= !callback( elems
[ i
], i
) )
1756 ret
.push( elems
[ i
] );
1761 map: function( elems
, callback
) {
1763 /// Translate all items in an array to another array of items.
1764 /// The translation function that is provided to this method is
1765 /// called for each item in the array and is passed one argument:
1766 /// The item to be translated.
1767 /// The function can then return the translated value, 'null'
1768 /// (to remove the item), or an array of values - which will
1769 /// be flattened into the full array.
1770 /// Part of JavaScript
1772 /// <returns type="Array" />
1773 /// <param name="elems" type="Array">
1774 /// array The Array to translate.
1776 /// <param name="fn" type="Function">
1777 /// The function to process each item against.
1782 // Go through the array, translating each of the items to their
1783 // new value (or values).
1784 for ( var i
= 0, length
= elems
.length
; i
< length
; i
++ ) {
1785 var value
= callback( elems
[ i
], i
);
1787 if ( value
!= null )
1788 ret
[ ret
.length
] = value
;
1791 return ret
.concat
.apply( [], ret
);
1795 // Use of jQuery.browser is deprecated.
1796 // It's included for backwards compatibility and plugins,
1797 // although they should work to migrate away.
1799 var userAgent
= navigator
.userAgent
.toLowerCase();
1801 // Figure out what browser is being used
1803 version
: (userAgent
.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
1804 safari
: /webkit/.test( userAgent
),
1805 opera
: /opera/.test( userAgent
),
1806 msie
: /msie/.test( userAgent
) && !/opera/.test( userAgent
),
1807 mozilla
: /mozilla/.test( userAgent
) && !/(compatible|webkit)/.test( userAgent
)
1810 // [vsdoc] The following section has been denormalized from original sources for IntelliSense.
1812 // parent: function(elem){return elem.parentNode;},
1813 // parents: function(elem){return jQuery.dir(elem,"parentNode");},
1814 // next: function(elem){return jQuery.nth(elem,2,"nextSibling");},
1815 // prev: function(elem){return jQuery.nth(elem,2,"previousSibling");},
1816 // nextAll: function(elem){return jQuery.dir(elem,"nextSibling");},
1817 // prevAll: function(elem){return jQuery.dir(elem,"previousSibling");},
1818 // siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);},
1819 // children: function(elem){return jQuery.sibling(elem.firstChild);},
1820 // contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);}
1821 // }, function(name, fn){
1822 // jQuery.fn[ name ] = function( selector ) {
1824 // /// Get a set of elements containing the unique parents of the matched
1825 // /// set of elements.
1826 // /// Can be filtered with an optional expressions.
1827 // /// Part of DOM/Traversing
1829 // /// <param name="expr" type="String" optional="true">
1830 // /// (optional) An expression to filter the parents with
1832 // /// <returns type="jQuery" />
1834 // var ret = jQuery.map( this, fn );
1836 // if ( selector && typeof selector == "string" )
1837 // ret = jQuery.multiFilter( selector, ret );
1839 // return this.pushStack( jQuery.unique( ret ), name, selector );
1844 parent: function(elem
){return elem
.parentNode
;}
1845 }, function(name
, fn
){
1846 jQuery
.fn
[ name
] = function( selector
) {
1848 /// Get a set of elements containing the unique parents of the matched
1849 /// set of elements.
1850 /// Can be filtered with an optional expressions.
1851 /// Part of DOM/Traversing
1853 /// <param name="expr" type="String" optional="true">
1854 /// (optional) An expression to filter the parents with
1856 /// <returns type="jQuery" />
1858 var ret
= jQuery
.map( this, fn
);
1860 if ( selector
&& typeof selector
== "string" )
1861 ret
= jQuery
.multiFilter( selector
, ret
);
1863 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
1868 parents: function(elem
){return jQuery
.dir(elem
,"parentNode");}
1869 }, function(name
, fn
){
1870 jQuery
.fn
[ name
] = function( selector
) {
1872 /// Get a set of elements containing the unique ancestors of the matched
1873 /// set of elements (except for the root element).
1874 /// Can be filtered with an optional expressions.
1875 /// Part of DOM/Traversing
1877 /// <param name="expr" type="String" optional="true">
1878 /// (optional) An expression to filter the ancestors with
1880 /// <returns type="jQuery" />
1882 var ret
= jQuery
.map( this, fn
);
1884 if ( selector
&& typeof selector
== "string" )
1885 ret
= jQuery
.multiFilter( selector
, ret
);
1887 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
1892 next: function(elem
){return jQuery
.nth(elem
,2,"nextSibling");}
1893 }, function(name
, fn
){
1894 jQuery
.fn
[ name
] = function( selector
) {
1896 /// Get a set of elements containing the unique next siblings of each of the
1897 /// matched set of elements.
1898 /// It only returns the very next sibling, not all next siblings.
1899 /// Can be filtered with an optional expressions.
1900 /// Part of DOM/Traversing
1902 /// <param name="expr" type="String" optional="true">
1903 /// (optional) An expression to filter the next Elements with
1905 /// <returns type="jQuery" />
1907 var ret
= jQuery
.map( this, fn
);
1909 if ( selector
&& typeof selector
== "string" )
1910 ret
= jQuery
.multiFilter( selector
, ret
);
1912 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
1917 prev: function(elem
){return jQuery
.nth(elem
,2,"previousSibling");}
1918 }, function(name
, fn
){
1919 jQuery
.fn
[ name
] = function( selector
) {
1921 /// Get a set of elements containing the unique previous siblings of each of the
1922 /// matched set of elements.
1923 /// Can be filtered with an optional expressions.
1924 /// It only returns the immediately previous sibling, not all previous siblings.
1925 /// Part of DOM/Traversing
1927 /// <param name="expr" type="String" optional="true">
1928 /// (optional) An expression to filter the previous Elements with
1930 /// <returns type="jQuery" />
1932 var ret
= jQuery
.map( this, fn
);
1934 if ( selector
&& typeof selector
== "string" )
1935 ret
= jQuery
.multiFilter( selector
, ret
);
1937 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
1942 nextAll: function(elem
){return jQuery
.dir(elem
,"nextSibling");}
1943 }, function(name
, fn
){
1944 jQuery
.fn
[name
] = function(selector
) {
1946 /// Finds all sibling elements after the current element.
1947 /// Can be filtered with an optional expressions.
1948 /// Part of DOM/Traversing
1950 /// <param name="expr" type="String" optional="true">
1951 /// (optional) An expression to filter the next Elements with
1953 /// <returns type="jQuery" />
1955 var ret
= jQuery
.map( this, fn
);
1957 if ( selector
&& typeof selector
== "string" )
1958 ret
= jQuery
.multiFilter( selector
, ret
);
1960 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
1965 prevAll: function(elem
){return jQuery
.dir(elem
,"previousSibling");}
1966 }, function(name
, fn
){
1967 jQuery
.fn
[ name
] = function( selector
) {
1969 /// Finds all sibling elements before the current element.
1970 /// Can be filtered with an optional expressions.
1971 /// Part of DOM/Traversing
1973 /// <param name="expr" type="String" optional="true">
1974 /// (optional) An expression to filter the previous Elements with
1976 /// <returns type="jQuery" />
1978 var ret
= jQuery
.map( this, fn
);
1980 if ( selector
&& typeof selector
== "string" )
1981 ret
= jQuery
.multiFilter( selector
, ret
);
1983 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
1988 siblings: function(elem
){return jQuery
.sibling(elem
.parentNode
.firstChild
,elem
);}
1989 }, function(name
, fn
){
1990 jQuery
.fn
[ name
] = function( selector
) {
1992 /// Get a set of elements containing all of the unique siblings of each of the
1993 /// matched set of elements.
1994 /// Can be filtered with an optional expressions.
1995 /// Part of DOM/Traversing
1997 /// <param name="expr" type="String" optional="true">
1998 /// (optional) An expression to filter the sibling Elements with
2000 /// <returns type="jQuery" />
2002 var ret
= jQuery
.map( this, fn
);
2004 if ( selector
&& typeof selector
== "string" )
2005 ret
= jQuery
.multiFilter( selector
, ret
);
2007 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
2012 children: function(elem
){return jQuery
.sibling(elem
.firstChild
);}
2013 }, function(name
, fn
){
2014 jQuery
.fn
[ name
] = function( selector
) {
2016 /// Get a set of elements containing all of the unique children of each of the
2017 /// matched set of elements.
2018 /// Can be filtered with an optional expressions.
2019 /// Part of DOM/Traversing
2021 /// <param name="expr" type="String" optional="true">
2022 /// (optional) An expression to filter the child Elements with
2024 /// <returns type="jQuery" />
2026 var ret
= jQuery
.map( this, fn
);
2028 if ( selector
&& typeof selector
== "string" )
2029 ret
= jQuery
.multiFilter( selector
, ret
);
2031 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
2036 contents: function(elem
){return jQuery
.nodeName(elem
,"iframe")?elem
.contentDocument
||elem
.contentWindow
.document
:jQuery
.makeArray(elem
.childNodes
);}
2037 }, function(name
, fn
){
2038 jQuery
.fn
[ name
] = function( selector
) {
2039 /// <summary>Finds all the child nodes inside the matched elements including text nodes, or the content document if the element is an iframe.</summary>
2040 /// <returns type="jQuery" />
2042 var ret
= jQuery
.map( this, fn
);
2044 if ( selector
&& typeof selector
== "string" )
2045 ret
= jQuery
.multiFilter( selector
, ret
);
2047 return this.pushStack( jQuery
.unique( ret
), name
, selector
);
2051 // [vsdoc] The following section has been denormalized from original sources for IntelliSense.
2053 // appendTo: "append",
2054 // prependTo: "prepend",
2055 // insertBefore: "before",
2056 // insertAfter: "after",
2057 // replaceAll: "replaceWith"
2058 // }, function(name, original){
2059 // jQuery.fn[ name ] = function() {
2060 // var args = arguments;
2062 // return this.each(function(){
2063 // for ( var i = 0, length = args.length; i < length; i++ )
2064 // jQuery( args[ i ] )[ original ]( this );
2069 jQuery
.fn
.appendTo = function( selector
) {
2071 /// Append all of the matched elements to another, specified, set of elements.
2072 /// As of jQuery 1.3.2, returns all of the inserted elements.
2073 /// This operation is, essentially, the reverse of doing a regular
2074 /// $(A).append(B), in that instead of appending B to A, you're appending
2077 /// <param name="selector" type="Selector">
2078 /// target to which the content will be appended.
2080 /// <returns type="jQuery" />
2081 var ret
= [], insert
= jQuery( selector
);
2083 for ( var i
= 0, l
= insert
.length
; i
< l
; i
++ ) {
2084 var elems
= (i
> 0 ? this.clone(true) : this).get();
2085 jQuery
.fn
[ "append" ].apply( jQuery(insert
[i
]), elems
);
2086 ret
= ret
.concat( elems
);
2089 return this.pushStack( ret
, "appendTo", selector
);
2092 jQuery
.fn
.prependTo = function( selector
) {
2094 /// Prepend all of the matched elements to another, specified, set of elements.
2095 /// As of jQuery 1.3.2, returns all of the inserted elements.
2096 /// This operation is, essentially, the reverse of doing a regular
2097 /// $(A).prepend(B), in that instead of prepending B to A, you're prepending
2100 /// <param name="selector" type="Selector">
2101 /// target to which the content will be appended.
2103 /// <returns type="jQuery" />
2104 var ret
= [], insert
= jQuery( selector
);
2106 for ( var i
= 0, l
= insert
.length
; i
< l
; i
++ ) {
2107 var elems
= (i
> 0 ? this.clone(true) : this).get();
2108 jQuery
.fn
[ "prepend" ].apply( jQuery(insert
[i
]), elems
);
2109 ret
= ret
.concat( elems
);
2112 return this.pushStack( ret
, "prependTo", selector
);
2115 jQuery
.fn
.insertBefore = function( selector
) {
2117 /// Insert all of the matched elements before another, specified, set of elements.
2118 /// As of jQuery 1.3.2, returns all of the inserted elements.
2119 /// This operation is, essentially, the reverse of doing a regular
2120 /// $(A).before(B), in that instead of inserting B before A, you're inserting
2123 /// <param name="content" type="String">
2124 /// Content after which the selected element(s) is inserted.
2126 /// <returns type="jQuery" />
2127 var ret
= [], insert
= jQuery( selector
);
2129 for ( var i
= 0, l
= insert
.length
; i
< l
; i
++ ) {
2130 var elems
= (i
> 0 ? this.clone(true) : this).get();
2131 jQuery
.fn
[ "before" ].apply( jQuery(insert
[i
]), elems
);
2132 ret
= ret
.concat( elems
);
2135 return this.pushStack( ret
, "insertBefore", selector
);
2138 jQuery
.fn
.insertAfter = function( selector
) {
2140 /// Insert all of the matched elements after another, specified, set of elements.
2141 /// As of jQuery 1.3.2, returns all of the inserted elements.
2142 /// This operation is, essentially, the reverse of doing a regular
2143 /// $(A).after(B), in that instead of inserting B after A, you're inserting
2146 /// <param name="content" type="String">
2147 /// Content after which the selected element(s) is inserted.
2149 /// <returns type="jQuery" />
2150 var ret
= [], insert
= jQuery( selector
);
2152 for ( var i
= 0, l
= insert
.length
; i
< l
; i
++ ) {
2153 var elems
= (i
> 0 ? this.clone(true) : this).get();
2154 jQuery
.fn
[ "after" ].apply( jQuery(insert
[i
]), elems
);
2155 ret
= ret
.concat( elems
);
2158 return this.pushStack( ret
, "insertAfter", selector
);
2161 jQuery
.fn
.replaceAll = function( selector
) {
2163 /// Replaces the elements matched by the specified selector with the matched elements.
2164 /// As of jQuery 1.3.2, returns all of the inserted elements.
2166 /// <param name="selector" type="Selector">The elements to find and replace the matched elements with.</param>
2167 /// <returns type="jQuery" />
2168 var ret
= [], insert
= jQuery( selector
);
2170 for ( var i
= 0, l
= insert
.length
; i
< l
; i
++ ) {
2171 var elems
= (i
> 0 ? this.clone(true) : this).get();
2172 jQuery
.fn
[ "replaceWith" ].apply( jQuery(insert
[i
]), elems
);
2173 ret
= ret
.concat( elems
);
2176 return this.pushStack( ret
, "replaceAll", selector
);
2179 // [vsdoc] The following section has been denormalized from original sources for IntelliSense.
2181 // removeAttr: function( name ) {
2182 // jQuery.attr( this, name, "" );
2183 // if (this.nodeType == 1)
2184 // this.removeAttribute( name );
2187 // addClass: function( classNames ) {
2188 // jQuery.className.add( this, classNames );
2191 // removeClass: function( classNames ) {
2192 // jQuery.className.remove( this, classNames );
2195 // toggleClass: function( classNames, state ) {
2196 // if( typeof state !== "boolean" )
2197 // state = !jQuery.className.has( this, classNames );
2198 // jQuery.className[ state ? "add" : "remove" ]( this, classNames );
2201 // remove: function( selector ) {
2202 // if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
2203 // // Prevent memory leaks
2204 // jQuery( "*", this ).add([this]).each(function(){
2205 // jQuery.event.remove(this);
2206 // jQuery.removeData(this);
2208 // if (this.parentNode)
2209 // this.parentNode.removeChild( this );
2213 // empty: function() {
2214 // // Remove element nodes and prevent memory leaks
2215 // jQuery( ">*", this ).remove();
2217 // // Remove any remaining nodes
2218 // while ( this.firstChild )
2219 // this.removeChild( this.firstChild );
2221 // }, function(name, fn){
2222 // jQuery.fn[ name ] = function(){
2223 // return this.each( fn, arguments );
2227 jQuery
.fn
.removeAttr = function(){
2229 /// Remove an attribute from each of the matched elements.
2230 /// Part of DOM/Attributes
2232 /// <param name="key" type="String">
2233 /// name The name of the attribute to remove.
2235 /// <returns type="jQuery" />
2236 return this.each( function( name
) {
2237 jQuery
.attr( this, name
, "" );
2238 if (this.nodeType
== 1)
2239 this.removeAttribute( name
);
2243 jQuery
.fn
.addClass = function(){
2245 /// Adds the specified class(es) to each of the set of matched elements.
2246 /// Part of DOM/Attributes
2248 /// <param name="classNames" type="String">
2249 /// lass One or more CSS classes to add to the elements
2251 /// <returns type="jQuery" />
2252 return this.each( function( classNames
) {
2253 jQuery
.className
.add( this, classNames
);
2257 jQuery
.fn
.removeClass = function(){
2259 /// Removes all or the specified class(es) from the set of matched elements.
2260 /// Part of DOM/Attributes
2262 /// <param name="cssClasses" type="String" optional="true">
2263 /// (Optional) One or more CSS classes to remove from the elements
2265 /// <returns type="jQuery" />
2266 return this.each( function( classNames
) {
2267 jQuery
.className
.remove( this, classNames
);
2271 jQuery
.fn
.toggleClass = function(){
2273 /// Adds the specified class if it is not present, removes it if it is
2275 /// Part of DOM/Attributes
2277 /// <param name="cssClass" type="String">
2278 /// A CSS class with which to toggle the elements
2280 /// <returns type="jQuery" />
2281 return this.each( function( classNames
, state
) {
2282 if( typeof state
!== "boolean" )
2283 state
= !jQuery
.className
.has( this, classNames
);
2284 jQuery
.className
[ state
? "add" : "remove" ]( this, classNames
);
2288 jQuery
.fn
.remove = function(){
2290 /// Removes all matched elements from the DOM. This does NOT remove them from the
2291 /// jQuery object, allowing you to use the matched elements further.
2292 /// Can be filtered with an optional expressions.
2293 /// Part of DOM/Manipulation
2295 /// <param name="expr" type="String" optional="true">
2296 /// (optional) A jQuery expression to filter elements by.
2298 /// <returns type="jQuery" />
2299 return this.each( function( selector
) {
2300 if ( !selector
|| jQuery
.filter( selector
, [ this ] ).length
) {
2301 // Prevent memory leaks
2302 jQuery( "*", this ).add([this]).each(function(){
2303 jQuery
.event
.remove(this);
2304 jQuery
.removeData(this);
2306 if (this.parentNode
)
2307 this.parentNode
.removeChild( this );
2312 jQuery
.fn
.empty = function(){
2314 /// Removes all child nodes from the set of matched elements.
2315 /// Part of DOM/Manipulation
2317 /// <returns type="jQuery" />
2318 return this.each( function() {
2319 // Remove element nodes and prevent memory leaks
2320 jQuery(this).children().remove();
2322 // Remove any remaining nodes
2323 while ( this.firstChild
)
2324 this.removeChild( this.firstChild
);
2328 // Helper function used by the dimensions and offset modules
2329 function num(elem
, prop
) {
2330 return elem
[0] && parseInt( jQuery
.curCSS(elem
[0], prop
, true), 10 ) || 0;
2332 var expando
= "jQuery" + now(), uuid
= 0, windowData
= {};
2337 data: function( elem
, name
, data
) {
2338 elem
= elem
== window
?
2342 var id
= elem
[ expando
];
2344 // Compute a unique ID for the element
2346 id
= elem
[ expando
] = ++uuid
;
2348 // Only generate the data cache if we're
2349 // trying to access or manipulate it
2350 if ( name
&& !jQuery
.cache
[ id
] )
2351 jQuery
.cache
[ id
] = {};
2353 // Prevent overriding the named cache with undefined values
2354 if ( data
!== undefined )
2355 jQuery
.cache
[ id
][ name
] = data
;
2357 // Return the named cache data, or the ID for the element
2359 jQuery
.cache
[ id
][ name
] :
2363 removeData: function( elem
, name
) {
2364 elem
= elem
== window
?
2368 var id
= elem
[ expando
];
2370 // If we want to remove a specific section of the element's data
2372 if ( jQuery
.cache
[ id
] ) {
2373 // Remove the section of cache data
2374 delete jQuery
.cache
[ id
][ name
];
2376 // If we've removed all the data, remove the element's cache
2379 for ( name
in jQuery
.cache
[ id
] )
2383 jQuery
.removeData( elem
);
2386 // Otherwise, we want to remove all of the element's data
2388 // Clean up the element expando
2390 delete elem
[ expando
];
2392 // IE has trouble directly removing the expando
2393 // but it's ok with using removeAttribute
2394 if ( elem
.removeAttribute
)
2395 elem
.removeAttribute( expando
);
2398 // Completely remove the data cache
2399 delete jQuery
.cache
[ id
];
2402 queue: function( elem
, type
, data
) {
2405 type
= (type
|| "fx") + "queue";
2407 var q
= jQuery
.data( elem
, type
);
2409 if ( !q
|| jQuery
.isArray(data
) )
2410 q
= jQuery
.data( elem
, type
, jQuery
.makeArray(data
) );
2418 dequeue: function( elem
, type
){
2419 var queue
= jQuery
.queue( elem
, type
),
2422 if( !type
|| type
=== "fx" )
2425 if( fn
!== undefined )
2431 data: function( key
, value
){
2432 var parts
= key
.split(".");
2433 parts
[1] = parts
[1] ? "." + parts
[1] : "";
2435 if ( value
=== undefined ) {
2436 var data
= this.triggerHandler("getData" + parts
[1] + "!", [parts
[0]]);
2438 if ( data
=== undefined && this.length
)
2439 data
= jQuery
.data( this[0], key
);
2441 return data
=== undefined && parts
[1] ?
2442 this.data( parts
[0] ) :
2445 return this.trigger("setData" + parts
[1] + "!", [parts
[0], value
]).each(function(){
2446 jQuery
.data( this, key
, value
);
2450 removeData: function( key
){
2451 return this.each(function(){
2452 jQuery
.removeData( this, key
);
2455 queue: function(type
, data
){
2457 /// 1: queue() - Returns a reference to the first element's queue (which is an array of functions).
2458 /// 2: queue(callback) - Adds a new function, to be executed, onto the end of the queue of all matched elements.
2459 /// 3: queue(queue) - Replaces the queue of all matched element with this new queue (the array of functions).
2461 /// <param name="type" type="Function">The function to add to the queue.</param>
2462 /// <returns type="jQuery" />
2464 if ( typeof type
!== "string" ) {
2469 if ( data
=== undefined )
2470 return jQuery
.queue( this[0], type
);
2472 return this.each(function(){
2473 var queue
= jQuery
.queue( this, type
, data
);
2475 if( type
== "fx" && queue
.length
== 1 )
2476 queue
[0].call(this);
2479 dequeue: function(type
){
2481 /// Removes a queued function from the front of the queue and executes it.
2483 /// <param name="type" type="String" optional="true">The type of queue to access.</param>
2484 /// <returns type="jQuery" />
2486 return this.each(function(){
2487 jQuery
.dequeue( this, type
);
2491 * Sizzle CSS Selector Engine - v0.9.3
2492 * Copyright 2009, The Dojo Foundation
2493 * More information: http://sizzlejs.com/
2495 * Permission is hereby granted, free of charge, to any person obtaining a copy
2496 * of this software and associated documentation files (the "Software"), to deal
2497 * in the Software without restriction, including without limitation the rights
2498 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2499 * copies of the Software, and to permit persons to whom the Software is
2500 * furnished to do so, subject to the following conditions:
2502 * The above copyright notice and this permission notice shall be included in
2503 * all copies or substantial portions of the Software.
2505 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2506 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2507 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2508 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2509 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2510 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2516 var chunker
= /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
2518 toString
= Object
.prototype.toString
;
2520 var Sizzle = function(selector
, context
, results
, seed
) {
2521 results
= results
|| [];
2522 context
= context
|| document
;
2524 if ( context
.nodeType
!== 1 && context
.nodeType
!== 9 )
2527 if ( !selector
|| typeof selector
!== "string" ) {
2531 var parts
= [], m
, set, checkSet
, check
, mode
, extra
, prune
= true;
2533 // Reset the position of the chunker regexp (start from head)
2534 chunker
.lastIndex
= 0;
2536 while ( (m
= chunker
.exec(selector
)) !== null ) {
2540 extra
= RegExp
.rightContext
;
2545 if ( parts
.length
> 1 && origPOS
.exec( selector
) ) {
2546 if ( parts
.length
=== 2 && Expr
.relative
[ parts
[0] ] ) {
2547 set = posProcess( parts
[0] + parts
[1], context
);
2549 set = Expr
.relative
[ parts
[0] ] ?
2551 Sizzle( parts
.shift(), context
);
2553 while ( parts
.length
) {
2554 selector
= parts
.shift();
2556 if ( Expr
.relative
[ selector
] )
2557 selector
+= parts
.shift();
2559 set = posProcess( selector
, set );
2564 { expr
: parts
.pop(), set: makeArray(seed
) } :
2565 Sizzle
.find( parts
.pop(), parts
.length
=== 1 && context
.parentNode
? context
.parentNode
: context
, isXML(context
) );
2566 set = Sizzle
.filter( ret
.expr
, ret
.set );
2568 if ( parts
.length
> 0 ) {
2569 checkSet
= makeArray(set);
2574 while ( parts
.length
) {
2575 var cur
= parts
.pop(), pop
= cur
;
2577 if ( !Expr
.relative
[ cur
] ) {
2583 if ( pop
== null ) {
2587 Expr
.relative
[ cur
]( checkSet
, pop
, isXML(context
) );
2596 throw "Syntax error, unrecognized expression: " + (cur
|| selector
);
2599 if ( toString
.call(checkSet
) === "[object Array]" ) {
2601 results
.push
.apply( results
, checkSet
);
2602 } else if ( context
.nodeType
=== 1 ) {
2603 for ( var i
= 0; checkSet
[i
] != null; i
++ ) {
2604 if ( checkSet
[i
] && (checkSet
[i
] === true || checkSet
[i
].nodeType
=== 1 && contains(context
, checkSet
[i
])) ) {
2605 results
.push( set[i
] );
2609 for ( var i
= 0; checkSet
[i
] != null; i
++ ) {
2610 if ( checkSet
[i
] && checkSet
[i
].nodeType
=== 1 ) {
2611 results
.push( set[i
] );
2616 makeArray( checkSet
, results
);
2620 Sizzle( extra
, context
, results
, seed
);
2623 hasDuplicate
= false;
2624 results
.sort(sortOrder
);
2626 if ( hasDuplicate
) {
2627 for ( var i
= 1; i
< results
.length
; i
++ ) {
2628 if ( results
[i
] === results
[i
-1] ) {
2629 results
.splice(i
--, 1);
2639 Sizzle
.matches = function(expr
, set){
2640 return Sizzle(expr
, null, null, set);
2643 Sizzle
.find = function(expr
, context
, isXML
){
2650 for ( var i
= 0, l
= Expr
.order
.length
; i
< l
; i
++ ) {
2651 var type
= Expr
.order
[i
], match
;
2653 if ( (match
= Expr
.match
[ type
].exec( expr
)) ) {
2654 var left
= RegExp
.leftContext
;
2656 if ( left
.substr( left
.length
- 1 ) !== "\\" ) {
2657 match
[1] = (match
[1] || "").replace(/\\/g
, "");
2658 set = Expr
.find
[ type
]( match
, context
, isXML
);
2659 if ( set != null ) {
2660 expr
= expr
.replace( Expr
.match
[ type
], "" );
2668 set = context
.getElementsByTagName("*");
2671 return {set: set, expr
: expr
};
2674 Sizzle
.filter = function(expr
, set, inplace
, not
){
2675 var old
= expr
, result
= [], curLoop
= set, match
, anyFound
,
2676 isXMLFilter
= set && set[0] && isXML(set[0]);
2678 while ( expr
&& set.length
) {
2679 for ( var type
in Expr
.filter
) {
2680 if ( (match
= Expr
.match
[ type
].exec( expr
)) != null ) {
2681 var filter
= Expr
.filter
[ type
], found
, item
;
2684 if ( curLoop
== result
) {
2688 if ( Expr
.preFilter
[ type
] ) {
2689 match
= Expr
.preFilter
[ type
]( match
, curLoop
, inplace
, result
, not
, isXMLFilter
);
2692 anyFound
= found
= true;
2693 } else if ( match
=== true ) {
2699 for ( var i
= 0; (item
= curLoop
[i
]) != null; i
++ ) {
2701 found
= filter( item
, match
, i
, curLoop
);
2702 var pass
= not
^ !!found
;
2704 if ( inplace
&& found
!= null ) {
2710 } else if ( pass
) {
2711 result
.push( item
);
2718 if ( found
!== undefined ) {
2723 expr
= expr
.replace( Expr
.match
[ type
], "" );
2734 // Improper expression
2735 if ( expr
== old
) {
2736 if ( anyFound
== null ) {
2737 throw "Syntax error, unrecognized expression: " + expr
;
2749 var Expr
= Sizzle
.selectors
= {
2750 order
: [ "ID", "NAME", "TAG" ],
2752 ID
: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
2753 CLASS
: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
2754 NAME
: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,
2755 ATTR
: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
2756 TAG
: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
2757 CHILD
: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
2758 POS
: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
2759 PSEUDO
: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
2762 "class": "className",
2766 href: function(elem
){
2767 return elem
.getAttribute("href");
2771 "+": function(checkSet
, part
, isXML
){
2772 var isPartStr
= typeof part
=== "string",
2773 isTag
= isPartStr
&& !/\W/.test(part
),
2774 isPartStrNotTag
= isPartStr
&& !isTag
;
2776 if ( isTag
&& !isXML
) {
2777 part
= part
.toUpperCase();
2780 for ( var i
= 0, l
= checkSet
.length
, elem
; i
< l
; i
++ ) {
2781 if ( (elem
= checkSet
[i
]) ) {
2782 while ( (elem
= elem
.previousSibling
) && elem
.nodeType
!== 1 ) {}
2784 checkSet
[i
] = isPartStrNotTag
|| elem
&& elem
.nodeName
=== part
?
2790 if ( isPartStrNotTag
) {
2791 Sizzle
.filter( part
, checkSet
, true );
2794 ">": function(checkSet
, part
, isXML
){
2795 var isPartStr
= typeof part
=== "string";
2797 if ( isPartStr
&& !/\W/.test(part
) ) {
2798 part
= isXML
? part
: part
.toUpperCase();
2800 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
2801 var elem
= checkSet
[i
];
2803 var parent
= elem
.parentNode
;
2804 checkSet
[i
] = parent
.nodeName
=== part
? parent
: false;
2808 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
2809 var elem
= checkSet
[i
];
2811 checkSet
[i
] = isPartStr
?
2813 elem
.parentNode
=== part
;
2818 Sizzle
.filter( part
, checkSet
, true );
2822 "": function(checkSet
, part
, isXML
){
2823 var doneName
= done
++, checkFn
= dirCheck
;
2825 if ( !part
.match(/\W/) ) {
2826 var nodeCheck
= part
= isXML
? part
: part
.toUpperCase();
2827 checkFn
= dirNodeCheck
;
2830 checkFn("parentNode", part
, doneName
, checkSet
, nodeCheck
, isXML
);
2832 "~": function(checkSet
, part
, isXML
){
2833 var doneName
= done
++, checkFn
= dirCheck
;
2835 if ( typeof part
=== "string" && !part
.match(/\W/) ) {
2836 var nodeCheck
= part
= isXML
? part
: part
.toUpperCase();
2837 checkFn
= dirNodeCheck
;
2840 checkFn("previousSibling", part
, doneName
, checkSet
, nodeCheck
, isXML
);
2844 ID: function(match
, context
, isXML
){
2845 if ( typeof context
.getElementById
!== "undefined" && !isXML
) {
2846 var m
= context
.getElementById(match
[1]);
2847 return m
? [m
] : [];
2850 NAME: function(match
, context
, isXML
){
2851 if ( typeof context
.getElementsByName
!== "undefined" ) {
2852 var ret
= [], results
= context
.getElementsByName(match
[1]);
2854 for ( var i
= 0, l
= results
.length
; i
< l
; i
++ ) {
2855 if ( results
[i
].getAttribute("name") === match
[1] ) {
2856 ret
.push( results
[i
] );
2860 return ret
.length
=== 0 ? null : ret
;
2863 TAG: function(match
, context
){
2864 return context
.getElementsByTagName(match
[1]);
2868 CLASS: function(match
, curLoop
, inplace
, result
, not
, isXML
){
2869 match
= " " + match
[1].replace(/\\/g
, "") + " ";
2875 for ( var i
= 0, elem
; (elem
= curLoop
[i
]) != null; i
++ ) {
2877 if ( not
^ (elem
.className
&& (" " + elem
.className
+ " ").indexOf(match
) >= 0) ) {
2879 result
.push( elem
);
2880 } else if ( inplace
) {
2888 ID: function(match
){
2889 return match
[1].replace(/\\/g
, "");
2891 TAG: function(match
, curLoop
){
2892 for ( var i
= 0; curLoop
[i
] === false; i
++ ){}
2893 return curLoop
[i
] && isXML(curLoop
[i
]) ? match
[1] : match
[1].toUpperCase();
2895 CHILD: function(match
){
2896 if ( match
[1] == "nth" ) {
2897 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
2898 var test
= /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
2899 match
[2] == "even" && "2n" || match
[2] == "odd" && "2n+1" ||
2900 !/\D/.test( match
[2] ) && "0n+" + match
[2] || match
[2]);
2902 // calculate the numbers (first)n+(last) including if they are negative
2903 match
[2] = (test
[1] + (test
[2] || 1)) - 0;
2904 match
[3] = test
[3] - 0;
2907 // TODO: Move to normal caching system
2912 ATTR: function(match
, curLoop
, inplace
, result
, not
, isXML
){
2913 var name
= match
[1].replace(/\\/g
, "");
2915 if ( !isXML
&& Expr
.attrMap
[name
] ) {
2916 match
[1] = Expr
.attrMap
[name
];
2919 if ( match
[2] === "~=" ) {
2920 match
[4] = " " + match
[4] + " ";
2925 PSEUDO: function(match
, curLoop
, inplace
, result
, not
){
2926 if ( match
[1] === "not" ) {
2927 // If we're dealing with a complex expression, or a simple one
2928 if ( match
[3].match(chunker
).length
> 1 || /^\w/.test(match
[3]) ) {
2929 match
[3] = Sizzle(match
[3], null, null, curLoop
);
2931 var ret
= Sizzle
.filter(match
[3], curLoop
, inplace
, true ^ not
);
2933 result
.push
.apply( result
, ret
);
2937 } else if ( Expr
.match
.POS
.test( match
[0] ) || Expr
.match
.CHILD
.test( match
[0] ) ) {
2943 POS: function(match
){
2944 match
.unshift( true );
2949 enabled: function(elem
){
2950 return elem
.disabled
=== false && elem
.type
!== "hidden";
2952 disabled: function(elem
){
2953 return elem
.disabled
=== true;
2955 checked: function(elem
){
2956 return elem
.checked
=== true;
2958 selected: function(elem
){
2959 // Accessing this property makes selected-by-default
2960 // options in Safari work properly
2961 elem
.parentNode
.selectedIndex
;
2962 return elem
.selected
=== true;
2964 parent: function(elem
){
2965 return !!elem
.firstChild
;
2967 empty: function(elem
){
2968 return !elem
.firstChild
;
2970 has: function(elem
, i
, match
){
2971 return !!Sizzle( match
[3], elem
).length
;
2973 header: function(elem
){
2974 return /h\d/i.test( elem
.nodeName
);
2976 text: function(elem
){
2977 return "text" === elem
.type
;
2979 radio: function(elem
){
2980 return "radio" === elem
.type
;
2982 checkbox: function(elem
){
2983 return "checkbox" === elem
.type
;
2985 file: function(elem
){
2986 return "file" === elem
.type
;
2988 password: function(elem
){
2989 return "password" === elem
.type
;
2991 submit: function(elem
){
2992 return "submit" === elem
.type
;
2994 image: function(elem
){
2995 return "image" === elem
.type
;
2997 reset: function(elem
){
2998 return "reset" === elem
.type
;
3000 button: function(elem
){
3001 return "button" === elem
.type
|| elem
.nodeName
.toUpperCase() === "BUTTON";
3003 input: function(elem
){
3004 return /input|select|textarea|button/i.test(elem
.nodeName
);
3008 first: function(elem
, i
){
3011 last: function(elem
, i
, match
, array
){
3012 return i
=== array
.length
- 1;
3014 even: function(elem
, i
){
3017 odd: function(elem
, i
){
3020 lt: function(elem
, i
, match
){
3021 return i
< match
[3] - 0;
3023 gt: function(elem
, i
, match
){
3024 return i
> match
[3] - 0;
3026 nth: function(elem
, i
, match
){
3027 return match
[3] - 0 == i
;
3029 eq: function(elem
, i
, match
){
3030 return match
[3] - 0 == i
;
3034 PSEUDO: function(elem
, match
, i
, array
){
3035 var name
= match
[1], filter
= Expr
.filters
[ name
];
3038 return filter( elem
, i
, match
, array
);
3039 } else if ( name
=== "contains" ) {
3040 return (elem
.textContent
|| elem
.innerText
|| "").indexOf(match
[3]) >= 0;
3041 } else if ( name
=== "not" ) {
3044 for ( var i
= 0, l
= not
.length
; i
< l
; i
++ ) {
3045 if ( not
[i
] === elem
) {
3053 CHILD: function(elem
, match
){
3054 var type
= match
[1], node
= elem
;
3058 while (node
= node
.previousSibling
) {
3059 if ( node
.nodeType
=== 1 ) return false;
3061 if ( type
== 'first') return true;
3064 while (node
= node
.nextSibling
) {
3065 if ( node
.nodeType
=== 1 ) return false;
3069 var first
= match
[2], last
= match
[3];
3071 if ( first
== 1 && last
== 0 ) {
3075 var doneName
= match
[0],
3076 parent
= elem
.parentNode
;
3078 if ( parent
&& (parent
.sizcache
!== doneName
|| !elem
.nodeIndex
) ) {
3080 for ( node
= parent
.firstChild
; node
; node
= node
.nextSibling
) {
3081 if ( node
.nodeType
=== 1 ) {
3082 node
.nodeIndex
= ++count
;
3085 parent
.sizcache
= doneName
;
3088 var diff
= elem
.nodeIndex
- last
;
3092 return ( diff
% first
== 0 && diff
/ first
>= 0 );
3096 ID: function(elem
, match
){
3097 return elem
.nodeType
=== 1 && elem
.getAttribute("id") === match
;
3099 TAG: function(elem
, match
){
3100 return (match
=== "*" && elem
.nodeType
=== 1) || elem
.nodeName
=== match
;
3102 CLASS: function(elem
, match
){
3103 return (" " + (elem
.className
|| elem
.getAttribute("class")) + " ")
3104 .indexOf( match
) > -1;
3106 ATTR: function(elem
, match
){
3107 var name
= match
[1],
3108 result
= Expr
.attrHandle
[ name
] ?
3109 Expr
.attrHandle
[ name
]( elem
) :
3110 elem
[ name
] != null ?
3112 elem
.getAttribute( name
),
3113 value
= result
+ "",
3117 return result
== null ?
3122 value
.indexOf(check
) >= 0 :
3124 (" " + value
+ " ").indexOf(check
) >= 0 :
3126 value
&& result
!== false :
3130 value
.indexOf(check
) === 0 :
3132 value
.substr(value
.length
- check
.length
) === check
:
3134 value
=== check
|| value
.substr(0, check
.length
+ 1) === check
+ "-" :
3137 POS: function(elem
, match
, i
, array
){
3138 var name
= match
[2], filter
= Expr
.setFilters
[ name
];
3141 return filter( elem
, i
, match
, array
);
3147 var origPOS
= Expr
.match
.POS
;
3149 for ( var type
in Expr
.match
) {
3150 Expr
.match
[ type
] = RegExp( Expr
.match
[ type
].source
+ /(?![^\[]*\])(?![^\(]*\))/.source
);
3153 var makeArray = function(array
, results
) {
3154 array
= Array
.prototype.slice
.call( array
);
3157 results
.push
.apply( results
, array
);
3164 // Perform a simple check to determine if the browser is capable of
3165 // converting a NodeList to an array using builtin methods.
3167 Array
.prototype.slice
.call( document
.documentElement
.childNodes
);
3169 // Provide a fallback method if it does not work
3171 makeArray = function(array
, results
) {
3172 var ret
= results
|| [];
3174 if ( toString
.call(array
) === "[object Array]" ) {
3175 Array
.prototype.push
.apply( ret
, array
);
3177 if ( typeof array
.length
=== "number" ) {
3178 for ( var i
= 0, l
= array
.length
; i
< l
; i
++ ) {
3179 ret
.push( array
[i
] );
3182 for ( var i
= 0; array
[i
]; i
++ ) {
3183 ret
.push( array
[i
] );
3194 if ( document
.documentElement
.compareDocumentPosition
) {
3195 sortOrder = function( a
, b
) {
3196 var ret
= a
.compareDocumentPosition(b
) & 4 ? -1 : a
=== b
? 0 : 1;
3198 hasDuplicate
= true;
3202 } else if ( "sourceIndex" in document
.documentElement
) {
3203 sortOrder = function( a
, b
) {
3204 var ret
= a
.sourceIndex
- b
.sourceIndex
;
3206 hasDuplicate
= true;
3210 } else if ( document
.createRange
) {
3211 sortOrder = function( a
, b
) {
3212 var aRange
= a
.ownerDocument
.createRange(), bRange
= b
.ownerDocument
.createRange();
3213 aRange
.selectNode(a
);
3214 aRange
.collapse(true);
3215 bRange
.selectNode(b
);
3216 bRange
.collapse(true);
3217 var ret
= aRange
.compareBoundaryPoints(Range
.START_TO_END
, bRange
);
3219 hasDuplicate
= true;
3225 // [vsdoc] The following function has been commented out for IntelliSense.
3226 // Check to see if the browser returns elements by name when
3227 // querying by getElementById (and provide a workaround)
3229 // // We're going to inject a fake input element with a specified name
3230 // var form = document.createElement("form"),
3231 // id = "script" + (new Date).getTime();
3232 // form.innerHTML = "<input name='" + id + "'/>";
3234 // // Inject it into the root element, check its status, and remove it quickly
3235 // var root = document.documentElement;
3236 // root.insertBefore( form, root.firstChild );
3238 // // The workaround has to do additional checks after a getElementById
3239 // // Which slows things down for other browsers (hence the branching)
3240 // if ( !!document.getElementById( id ) ) {
3241 // Expr.find.ID = function(match, context, isXML){
3242 // if ( typeof context.getElementById !== "undefined" && !isXML ) {
3243 // var m = context.getElementById(match[1]);
3244 // return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
3248 // Expr.filter.ID = function(elem, match){
3249 // var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
3250 // return elem.nodeType === 1 && node && node.nodeValue === match;
3254 // root.removeChild( form );
3257 // [vsdoc] The following function has been commented out for IntelliSense.
3259 // // Check to see if the browser returns only elements
3260 // // when doing getElementsByTagName("*")
3262 // // Create a fake element
3263 // var div = document.createElement("div");
3264 // div.appendChild( document.createComment("") );
3266 // // Make sure no comments are found
3267 // if ( div.getElementsByTagName("*").length > 0 ) {
3268 // Expr.find.TAG = function(match, context){
3269 // var results = context.getElementsByTagName(match[1]);
3271 // // Filter out possible comments
3272 // if ( match[1] === "*" ) {
3275 // for ( var i = 0; results[i]; i++ ) {
3276 // if ( results[i].nodeType === 1 ) {
3277 // tmp.push( results[i] );
3288 // // Check to see if an attribute returns normalized href attributes
3289 // div.innerHTML = "<a href='#'></a>";
3290 // if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
3291 // div.firstChild.getAttribute("href") !== "#" ) {
3292 // Expr.attrHandle.href = function(elem){
3293 // return elem.getAttribute("href", 2);
3298 if ( document
.querySelectorAll
) (function(){
3299 var oldSizzle
= Sizzle
, div
= document
.createElement("div");
3300 div
.innerHTML
= "<p class='TEST'></p>";
3302 // Safari can't handle uppercase or unicode characters when
3304 if ( div
.querySelectorAll
&& div
.querySelectorAll(".TEST").length
=== 0 ) {
3308 Sizzle = function(query
, context
, extra
, seed
){
3309 context
= context
|| document
;
3311 // Only use querySelectorAll on non-XML documents
3312 // (ID selectors don't work in non-HTML documents)
3313 if ( !seed
&& context
.nodeType
=== 9 && !isXML(context
) ) {
3315 return makeArray( context
.querySelectorAll(query
), extra
);
3319 return oldSizzle(query
, context
, extra
, seed
);
3322 Sizzle
.find
= oldSizzle
.find
;
3323 Sizzle
.filter
= oldSizzle
.filter
;
3324 Sizzle
.selectors
= oldSizzle
.selectors
;
3325 Sizzle
.matches
= oldSizzle
.matches
;
3328 if ( document
.getElementsByClassName
&& document
.documentElement
.getElementsByClassName
) (function(){
3329 var div
= document
.createElement("div");
3330 div
.innerHTML
= "<div class='test e'></div><div class='test'></div>";
3332 // Opera can't find a second classname (in 9.6)
3333 if ( div
.getElementsByClassName("e").length
=== 0 )
3336 // Safari caches class attributes, doesn't catch changes (in 3.2)
3337 div
.lastChild
.className
= "e";
3339 if ( div
.getElementsByClassName("e").length
=== 1 )
3342 Expr
.order
.splice(1, 0, "CLASS");
3343 Expr
.find
.CLASS = function(match
, context
, isXML
) {
3344 if ( typeof context
.getElementsByClassName
!== "undefined" && !isXML
) {
3345 return context
.getElementsByClassName(match
[1]);
3350 function dirNodeCheck( dir
, cur
, doneName
, checkSet
, nodeCheck
, isXML
) {
3351 var sibDir
= dir
== "previousSibling" && !isXML
;
3352 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
3353 var elem
= checkSet
[i
];
3355 if ( sibDir
&& elem
.nodeType
=== 1 ){
3356 elem
.sizcache
= doneName
;
3363 if ( elem
.sizcache
=== doneName
) {
3364 match
= checkSet
[elem
.sizset
];
3368 if ( elem
.nodeType
=== 1 && !isXML
){
3369 elem
.sizcache
= doneName
;
3373 if ( elem
.nodeName
=== cur
) {
3381 checkSet
[i
] = match
;
3386 function dirCheck( dir
, cur
, doneName
, checkSet
, nodeCheck
, isXML
) {
3387 var sibDir
= dir
== "previousSibling" && !isXML
;
3388 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
3389 var elem
= checkSet
[i
];
3391 if ( sibDir
&& elem
.nodeType
=== 1 ) {
3392 elem
.sizcache
= doneName
;
3399 if ( elem
.sizcache
=== doneName
) {
3400 match
= checkSet
[elem
.sizset
];
3404 if ( elem
.nodeType
=== 1 ) {
3406 elem
.sizcache
= doneName
;
3409 if ( typeof cur
!== "string" ) {
3410 if ( elem
=== cur
) {
3415 } else if ( Sizzle
.filter( cur
, [elem
] ).length
> 0 ) {
3424 checkSet
[i
] = match
;
3429 var contains
= document
.compareDocumentPosition
? function(a
, b
){
3430 return a
.compareDocumentPosition(b
) & 16;
3432 return a
!== b
&& (a
.contains
? a
.contains(b
) : true);
3435 var isXML = function(elem
){
3436 return elem
.nodeType
=== 9 && elem
.documentElement
.nodeName
!== "HTML" ||
3437 !!elem
.ownerDocument
&& isXML( elem
.ownerDocument
);
3440 var posProcess = function(selector
, context
){
3441 var tmpSet
= [], later
= "", match
,
3442 root
= context
.nodeType
? [context
] : context
;
3444 // Position selectors must be done after the filter
3445 // And so must :not(positional) so we move all PSEUDOs to the end
3446 while ( (match
= Expr
.match
.PSEUDO
.exec( selector
)) ) {
3448 selector
= selector
.replace( Expr
.match
.PSEUDO
, "" );
3451 selector
= Expr
.relative
[selector
] ? selector
+ "*" : selector
;
3453 for ( var i
= 0, l
= root
.length
; i
< l
; i
++ ) {
3454 Sizzle( selector
, root
[i
], tmpSet
);
3457 return Sizzle
.filter( later
, tmpSet
);
3461 jQuery
.find
= Sizzle
;
3462 jQuery
.filter
= Sizzle
.filter
;
3463 jQuery
.expr
= Sizzle
.selectors
;
3464 jQuery
.expr
[":"] = jQuery
.expr
.filters
;
3466 Sizzle
.selectors
.filters
.hidden = function(elem
){
3467 return elem
.offsetWidth
=== 0 || elem
.offsetHeight
=== 0;
3470 Sizzle
.selectors
.filters
.visible = function(elem
){
3471 return elem
.offsetWidth
> 0 || elem
.offsetHeight
> 0;
3474 Sizzle
.selectors
.filters
.animated = function(elem
){
3475 return jQuery
.grep(jQuery
.timers
, function(fn
){
3476 return elem
=== fn
.elem
;
3480 jQuery
.multiFilter = function( expr
, elems
, not
) {
3482 /// This member is internal only.
3487 expr
= ":not(" + expr
+ ")";
3490 return Sizzle
.matches(expr
, elems
);
3493 jQuery
.dir = function( elem
, dir
){
3495 /// This member is internal only.
3498 // This member is not documented in the jQuery API: http://docs.jquery.com/Special:Search?ns0=1&search=dir
3499 var matched
= [], cur
= elem
[dir
];
3500 while ( cur
&& cur
!= document
) {
3501 if ( cur
.nodeType
== 1 )
3502 matched
.push( cur
);
3508 jQuery
.nth = function(cur
, result
, dir
, elem
){
3510 /// This member is internal only.
3513 // This member is not documented in the jQuery API: http://docs.jquery.com/Special:Search?ns0=1&search=nth
3514 result
= result
|| 1;
3517 for ( ; cur
; cur
= cur
[dir
] )
3518 if ( cur
.nodeType
== 1 && ++num
== result
)
3524 jQuery
.sibling = function(n
, elem
){
3526 /// This member is internal only.
3529 // This member is not documented in the jQuery API: http://docs.jquery.com/Special:Search?ns0=1&search=nth
3532 for ( ; n
; n
= n
.nextSibling
) {
3533 if ( n
.nodeType
== 1 && n
!= elem
)
3542 window
.Sizzle
= Sizzle
;
3546 * A number of helper functions used for managing events.
3547 * Many of the ideas behind this code originated from
3548 * Dean Edwards' addEvent library.
3552 // Bind an event to an element
3553 // Original by Dean Edwards
3554 add: function(elem
, types
, handler
, data
) {
3556 /// This method is internal.
3559 if ( elem
.nodeType
== 3 || elem
.nodeType
== 8 )
3562 // For whatever reason, IE has trouble passing the window object
3563 // around, causing it to be cloned in the process
3564 if ( elem
.setInterval
&& elem
!= window
)
3567 // Make sure that the function being executed has a unique ID
3568 if ( !handler
.guid
)
3569 handler
.guid
= this.guid
++;
3571 // if data is passed, bind to handler
3572 if ( data
!== undefined ) {
3573 // Create temporary function pointer to original handler
3576 // Create unique handler function, wrapped around original handler
3577 handler
= this.proxy( fn
);
3579 // Store data in unique handler
3580 handler
.data
= data
;
3583 // Init the element's event structure
3584 var events
= jQuery
.data(elem
, "events") || jQuery
.data(elem
, "events", {}),
3585 handle
= jQuery
.data(elem
, "handle") || jQuery
.data(elem
, "handle", function(){
3586 // Handle the second event of a trigger and when
3587 // an event is called after a page has unloaded
3588 return typeof jQuery
!== "undefined" && !jQuery
.event
.triggered
?
3589 jQuery
.event
.handle
.apply(arguments
.callee
.elem
, arguments
) :
3592 // Add elem as a property of the handle function
3593 // This is to prevent a memory leak with non-native
3597 // Handle multiple events separated by a space
3598 // jQuery(...).bind("mouseover mouseout", fn);
3599 jQuery
.each(types
.split(/\s+/), function(index
, type
) {
3600 // Namespaced event handlers
3601 var namespaces
= type
.split(".");
3602 type
= namespaces
.shift();
3603 handler
.type
= namespaces
.slice().sort().join(".");
3605 // Get the current list of functions bound to this event
3606 var handlers
= events
[type
];
3608 if ( jQuery
.event
.specialAll
[type
] )
3609 jQuery
.event
.specialAll
[type
].setup
.call(elem
, data
, namespaces
);
3611 // Init the event handler queue
3613 handlers
= events
[type
] = {};
3615 // Check for a special event handler
3616 // Only use addEventListener/attachEvent if the special
3617 // events handler returns false
3618 if ( !jQuery
.event
.special
[type
] || jQuery
.event
.special
[type
].setup
.call(elem
, data
, namespaces
) === false ) {
3619 // Bind the global event handler to the element
3620 if (elem
.addEventListener
)
3621 elem
.addEventListener(type
, handle
, false);
3622 else if (elem
.attachEvent
)
3623 elem
.attachEvent("on" + type
, handle
);
3627 // Add the function to the element's handler list
3628 handlers
[handler
.guid
] = handler
;
3630 // Keep track of which events have been used, for global triggering
3631 jQuery
.event
.global
[type
] = true;
3634 // Nullify elem to prevent memory leaks in IE
3641 // Detach an event or set of events from an element
3642 remove: function(elem
, types
, handler
) {
3644 /// This method is internal.
3648 // don't do events on text and comment nodes
3649 if ( elem
.nodeType
== 3 || elem
.nodeType
== 8 )
3652 var events
= jQuery
.data(elem
, "events"), ret
, index
;
3655 // Unbind all events for the element
3656 if ( types
=== undefined || (typeof types
=== "string" && types
.charAt(0) == ".") )
3657 for ( var type
in events
)
3658 this.remove( elem
, type
+ (types
|| "") );
3660 // types is actually an event object here
3662 handler
= types
.handler
;
3666 // Handle multiple events seperated by a space
3667 // jQuery(...).unbind("mouseover mouseout", fn);
3668 jQuery
.each(types
.split(/\s+/), function(index
, type
){
3669 // Namespaced event handlers
3670 var namespaces
= type
.split(".");
3671 type
= namespaces
.shift();
3672 var namespace = RegExp("(^|\\.)" + namespaces
.slice().sort().join(".*\\.") + "(\\.|$)");
3674 if ( events
[type
] ) {
3675 // remove the given handler for the given type
3677 delete events
[type
][handler
.guid
];
3679 // remove all handlers for the given type
3681 for ( var handle
in events
[type
] )
3682 // Handle the removal of namespaced events
3683 if ( namespace.test(events
[type
][handle
].type
) )
3684 delete events
[type
][handle
];
3686 if ( jQuery
.event
.specialAll
[type
] )
3687 jQuery
.event
.specialAll
[type
].teardown
.call(elem
, namespaces
);
3689 // remove generic event handler if no more handlers exist
3690 for ( ret
in events
[type
] ) break;
3692 if ( !jQuery
.event
.special
[type
] || jQuery
.event
.special
[type
].teardown
.call(elem
, namespaces
) === false ) {
3693 if (elem
.removeEventListener
)
3694 elem
.removeEventListener(type
, jQuery
.data(elem
, "handle"), false);
3695 else if (elem
.detachEvent
)
3696 elem
.detachEvent("on" + type
, jQuery
.data(elem
, "handle"));
3699 delete events
[type
];
3705 // Remove the expando if it's no longer used
3706 for ( ret
in events
) break;
3708 var handle
= jQuery
.data( elem
, "handle" );
3709 if ( handle
) handle
.elem
= null;
3710 jQuery
.removeData( elem
, "events" );
3711 jQuery
.removeData( elem
, "handle" );
3716 // bubbling is internal
3717 trigger: function( event
, data
, elem
, bubbling
) {
3719 /// This method is internal.
3723 // Event object or event type
3724 var type
= event
.type
|| event
;
3727 event
= typeof event
=== "object" ?
3728 // jQuery.Event object
3729 event
[expando
] ? event
:
3731 jQuery
.extend( jQuery
.Event(type
), event
) :
3732 // Just the event type (string)
3735 if ( type
.indexOf("!") >= 0 ) {
3736 event
.type
= type
= type
.slice(0, -1);
3737 event
.exclusive
= true;
3740 // Handle a global trigger
3742 // Don't bubble custom events when global (to avoid too much overhead)
3743 event
.stopPropagation();
3744 // Only trigger if we've ever bound an event for it
3745 if ( this.global
[type
] )
3746 jQuery
.each( jQuery
.cache
, function(){
3747 if ( this.events
&& this.events
[type
] )
3748 jQuery
.event
.trigger( event
, data
, this.handle
.elem
);
3752 // Handle triggering a single element
3754 // don't do events on text and comment nodes
3755 if ( !elem
|| elem
.nodeType
== 3 || elem
.nodeType
== 8 )
3758 // Clean up in case it is reused
3759 event
.result
= undefined;
3760 event
.target
= elem
;
3762 // Clone the incoming data, if any
3763 data
= jQuery
.makeArray(data
);
3764 data
.unshift( event
);
3767 event
.currentTarget
= elem
;
3769 // Trigger the event, it is assumed that "handle" is a function
3770 var handle
= jQuery
.data(elem
, "handle");
3772 handle
.apply( elem
, data
);
3774 // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
3775 if ( (!elem
[type
] || (jQuery
.nodeName(elem
, 'a') && type
== "click")) && elem
["on"+type
] && elem
["on"+type
].apply( elem
, data
) === false )
3776 event
.result
= false;
3778 // Trigger the native events (except for clicks on links)
3779 if ( !bubbling
&& elem
[type
] && !event
.isDefaultPrevented() && !(jQuery
.nodeName(elem
, 'a') && type
== "click") ) {
3780 this.triggered
= true;
3783 // prevent IE from throwing an error for some hidden elements
3787 this.triggered
= false;
3789 if ( !event
.isPropagationStopped() ) {
3790 var parent
= elem
.parentNode
|| elem
.ownerDocument
;
3792 jQuery
.event
.trigger(event
, data
, parent
, true);
3796 handle: function(event
) {
3798 /// This method is internal.
3802 // returned undefined or false
3805 event
= arguments
[0] = jQuery
.event
.fix( event
|| window
.event
);
3806 event
.currentTarget
= this;
3808 // Namespaced event handlers
3809 var namespaces
= event
.type
.split(".");
3810 event
.type
= namespaces
.shift();
3812 // Cache this now, all = true means, any handler
3813 all
= !namespaces
.length
&& !event
.exclusive
;
3815 var namespace = RegExp("(^|\\.)" + namespaces
.slice().sort().join(".*\\.") + "(\\.|$)");
3817 handlers
= ( jQuery
.data(this, "events") || {} )[event
.type
];
3819 for ( var j
in handlers
) {
3820 var handler
= handlers
[j
];
3822 // Filter the functions by class
3823 if ( all
|| namespace.test(handler
.type
) ) {
3824 // Pass in a reference to the handler function itself
3825 // So that we can later remove it
3826 event
.handler
= handler
;
3827 event
.data
= handler
.data
;
3829 var ret
= handler
.apply(this, arguments
);
3831 if( ret
!== undefined ){
3833 if ( ret
=== false ) {
3834 event
.preventDefault();
3835 event
.stopPropagation();
3839 if( event
.isImmediatePropagationStopped() )
3846 props
: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
3848 fix: function(event
) {
3850 /// This method is internal.
3854 if ( event
[expando
] )
3857 // store a copy of the original event object
3858 // and "clone" to set read-only properties
3859 var originalEvent
= event
;
3860 event
= jQuery
.Event( originalEvent
);
3862 for ( var i
= this.props
.length
, prop
; i
; ){
3863 prop
= this.props
[ --i
];
3864 event
[ prop
] = originalEvent
[ prop
];
3867 // Fix target property, if necessary
3868 if ( !event
.target
)
3869 event
.target
= event
.srcElement
|| document
; // Fixes #1925 where srcElement might not be defined either
3871 // check if target is a textnode (safari)
3872 if ( event
.target
.nodeType
== 3 )
3873 event
.target
= event
.target
.parentNode
;
3875 // Add relatedTarget, if necessary
3876 if ( !event
.relatedTarget
&& event
.fromElement
)
3877 event
.relatedTarget
= event
.fromElement
== event
.target
? event
.toElement
: event
.fromElement
;
3879 // Calculate pageX/Y if missing and clientX/Y available
3880 if ( event
.pageX
== null && event
.clientX
!= null ) {
3881 var doc
= document
.documentElement
, body
= document
.body
;
3882 event
.pageX
= event
.clientX
+ (doc
&& doc
.scrollLeft
|| body
&& body
.scrollLeft
|| 0) - (doc
.clientLeft
|| 0);
3883 event
.pageY
= event
.clientY
+ (doc
&& doc
.scrollTop
|| body
&& body
.scrollTop
|| 0) - (doc
.clientTop
|| 0);
3886 // Add which for key events
3887 if ( !event
.which
&& ((event
.charCode
|| event
.charCode
=== 0) ? event
.charCode
: event
.keyCode
) )
3888 event
.which
= event
.charCode
|| event
.keyCode
;
3890 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
3891 if ( !event
.metaKey
&& event
.ctrlKey
)
3892 event
.metaKey
= event
.ctrlKey
;
3894 // Add which for click: 1 == left; 2 == middle; 3 == right
3895 // Note: button is not normalized, so don't use it
3896 if ( !event
.which
&& event
.button
)
3897 event
.which
= (event
.button
& 1 ? 1 : ( event
.button
& 2 ? 3 : ( event
.button
& 4 ? 2 : 0 ) ));
3902 proxy: function( fn
, proxy
){
3904 /// This method is internal.
3908 proxy
= proxy
|| function(){ return fn
.apply(this, arguments
); };
3909 // Set the guid of unique handler to the same of original handler, so it can be removed
3910 proxy
.guid
= fn
.guid
= fn
.guid
|| proxy
.guid
|| this.guid
++;
3911 // So proxy can be declared as an argument
3918 /// This method is internal.
3922 // Make sure the ready event is setup
3924 teardown: function() {}
3930 setup: function( selector
, namespaces
){
3931 jQuery
.event
.add( this, namespaces
[0], liveHandler
);
3933 teardown: function( namespaces
){
3934 if ( namespaces
.length
) {
3935 var remove
= 0, name
= RegExp("(^|\\.)" + namespaces
[0] + "(\\.|$)");
3937 jQuery
.each( (jQuery
.data(this, "events").live
|| {}), function(){
3938 if ( name
.test(this.type
) )
3943 jQuery
.event
.remove( this, namespaces
[0], liveHandler
);
3950 jQuery
.Event = function( src
){
3951 // Allow instantiation without the 'new' keyword
3952 if( !this.preventDefault
)
3953 return new jQuery
.Event(src
);
3956 if( src
&& src
.type
){
3957 this.originalEvent
= src
;
3958 this.type
= src
.type
;
3963 // timeStamp is buggy for some events on Firefox(#3843)
3964 // So we won't rely on the native value
3965 this.timeStamp
= now();
3968 this[expando
] = true;
3971 function returnFalse(){
3974 function returnTrue(){
3978 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3979 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3980 jQuery
.Event
.prototype = {
3981 preventDefault: function() {
3982 this.isDefaultPrevented
= returnTrue
;
3984 var e
= this.originalEvent
;
3987 // if preventDefault exists run it on the original event
3988 if (e
.preventDefault
)
3990 // otherwise set the returnValue property of the original event to false (IE)
3991 e
.returnValue
= false;
3993 stopPropagation: function() {
3994 this.isPropagationStopped
= returnTrue
;
3996 var e
= this.originalEvent
;
3999 // if stopPropagation exists run it on the original event
4000 if (e
.stopPropagation
)
4001 e
.stopPropagation();
4002 // otherwise set the cancelBubble property of the original event to true (IE)
4003 e
.cancelBubble
= true;
4005 stopImmediatePropagation:function(){
4006 this.isImmediatePropagationStopped
= returnTrue
;
4007 this.stopPropagation();
4009 isDefaultPrevented
: returnFalse
,
4010 isPropagationStopped
: returnFalse
,
4011 isImmediatePropagationStopped
: returnFalse
4013 // Checks if an event happened on an element within another element
4014 // Used in jQuery.event.special.mouseenter and mouseleave handlers
4015 var withinElement = function(event
) {
4016 // Check if mouse(over|out) are still within the same parent element
4017 var parent
= event
.relatedTarget
;
4018 // Traverse up the tree
4019 while ( parent
&& parent
!= this )
4020 try { parent
= parent
.parentNode
; }
4021 catch(e
) { parent
= this; }
4023 if( parent
!= this ){
4024 // set the correct event type
4025 event
.type
= event
.data
;
4026 // handle event if we actually just moused on to a non sub-element
4027 jQuery
.event
.handle
.apply( this, arguments
);
4032 mouseover
: 'mouseenter',
4033 mouseout
: 'mouseleave'
4034 }, function( orig
, fix
){
4035 jQuery
.event
.special
[ fix
] = {
4038 /// This method is internal.
4042 jQuery
.event
.add( this, orig
, withinElement
, fix
);
4044 teardown: function(){
4046 /// This method is internal.
4050 jQuery
.event
.remove( this, orig
, withinElement
);
4056 bind: function( type
, data
, fn
) {
4058 /// Binds a handler to one or more events for each matched element. Can also bind custom events.
4060 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
4061 /// <param name="data" optional="true" type="Object">Additional data passed to the event handler as event.data</param>
4062 /// <param name="fn" type="Function">A function to bind to the event on each of the set of matched elements. function callback(eventObject) such that this corresponds to the dom element.</param>
4064 return type
== "unload" ? this.one(type
, data
, fn
) : this.each(function(){
4065 jQuery
.event
.add( this, type
, fn
|| data
, fn
&& data
);
4069 one: function( type
, data
, fn
) {
4071 /// Binds a handler to one or more events to be executed exactly once for each matched element.
4073 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
4074 /// <param name="data" optional="true" type="Object">Additional data passed to the event handler as event.data</param>
4075 /// <param name="fn" type="Function">A function to bind to the event on each of the set of matched elements. function callback(eventObject) such that this corresponds to the dom element.</param>
4077 var one
= jQuery
.event
.proxy( fn
|| data
, function(event
) {
4078 jQuery(this).unbind(event
, one
);
4079 return (fn
|| data
).apply( this, arguments
);
4081 return this.each(function(){
4082 jQuery
.event
.add( this, type
, one
, fn
&& data
);
4086 unbind: function( type
, fn
) {
4088 /// Unbinds a handler from one or more events for each matched element.
4090 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
4091 /// <param name="fn" type="Function">A function to bind to the event on each of the set of matched elements. function callback(eventObject) such that this corresponds to the dom element.</param>
4093 return this.each(function(){
4094 jQuery
.event
.remove( this, type
, fn
);
4098 trigger: function( type
, data
) {
4100 /// Triggers a type of event on every matched element.
4102 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
4103 /// <param name="data" optional="true" type="Array">Additional data passed to the event handler as additional arguments.</param>
4104 /// <param name="fn" type="Function">This parameter is undocumented.</param>
4106 return this.each(function(){
4107 jQuery
.event
.trigger( type
, data
, this );
4111 triggerHandler: function( type
, data
) {
4113 /// Triggers all bound event handlers on an element for a specific event type without executing the browser's default actions.
4115 /// <param name="type" type="String">One or more event types separated by a space. Built-in event type values are: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, error .</param>
4116 /// <param name="data" optional="true" type="Array">Additional data passed to the event handler as additional arguments.</param>
4117 /// <param name="fn" type="Function">This parameter is undocumented.</param>
4120 var event
= jQuery
.Event(type
);
4121 event
.preventDefault();
4122 event
.stopPropagation();
4123 jQuery
.event
.trigger( event
, data
, this[0] );
4124 return event
.result
;
4128 toggle: function( fn
) {
4130 /// Toggles among two or more function calls every other click.
4132 /// <param name="fn" type="Function">The functions among which to toggle execution</param>
4134 // Save reference to arguments for access in closure
4135 var args
= arguments
, i
= 1;
4137 // link all the functions, so any of them can unbind this click handler
4138 while( i
< args
.length
)
4139 jQuery
.event
.proxy( fn
, args
[i
++] );
4141 return this.click( jQuery
.event
.proxy( fn
, function(event
) {
4142 // Figure out which function to execute
4143 this.lastToggle
= ( this.lastToggle
|| 0 ) % i
;
4145 // Make sure that clicks stop
4146 event
.preventDefault();
4148 // and execute the function
4149 return args
[ this.lastToggle
++ ].apply( this, arguments
) || false;
4153 hover: function(fnOver
, fnOut
) {
4155 /// Simulates hovering (moving the mouse on or off of an object).
4157 /// <param name="fnOver" type="Function">The function to fire when the mouse is moved over a matched element.</param>
4158 /// <param name="fnOut" type="Function">The function to fire when the mouse is moved off of a matched element.</param>
4160 return this.mouseenter(fnOver
).mouseleave(fnOut
);
4163 ready: function(fn
) {
4165 /// Binds a function to be executed whenever the DOM is ready to be traversed and manipulated.
4167 /// <param name="fn" type="Function">The function to be executed when the DOM is ready.</param>
4169 // Attach the listeners
4172 // If the DOM is already ready
4173 if ( jQuery
.isReady
)
4174 // Execute the function immediately
4175 fn
.call( document
, jQuery
);
4177 // Otherwise, remember the function for later
4179 // Add the function to the wait list
4180 jQuery
.readyList
.push( fn
);
4185 live: function( type
, fn
){
4187 /// Binds a handler to an event (like click) for all current - and future - matched element. Can also bind custom events.
4189 /// <param name="type" type="String">An event type</param>
4190 /// <param name="fn" type="Function">A function to bind to the event on each of the set of matched elements</param>
4192 var proxy
= jQuery
.event
.proxy( fn
);
4193 proxy
.guid
+= this.selector
+ type
;
4195 jQuery(document
).bind( liveConvert(type
, this.selector
), this.selector
, proxy
);
4200 die: function( type
, fn
){
4202 /// This does the opposite of live, it removes a bound live event.
4203 /// You can also unbind custom events registered with live.
4204 /// If the type is provided, all bound live events of that type are removed.
4205 /// If the function that was passed to live is provided as the second argument, only that specific event handler is removed.
4207 /// <param name="type" type="String">A live event type to unbind.</param>
4208 /// <param name="fn" type="Function">A function to unbind from the event on each of the set of matched elements.</param>
4210 jQuery(document
).unbind( liveConvert(type
, this.selector
), fn
? { guid
: fn
.guid
+ this.selector
+ type
} : null );
4215 function liveHandler( event
){
4216 var check
= RegExp("(^|\\.)" + event
.type
+ "(\\.|$)"),
4220 jQuery
.each(jQuery
.data(this, "events").live
|| [], function(i
, fn
){
4221 if ( check
.test(fn
.type
) ) {
4222 var elem
= jQuery(event
.target
).closest(fn
.data
)[0];
4224 elems
.push({ elem
: elem
, fn
: fn
});
4228 elems
.sort(function(a
,b
) {
4229 return jQuery
.data(a
.elem
, "closest") - jQuery
.data(b
.elem
, "closest");
4232 jQuery
.each(elems
, function(){
4233 if ( this.fn
.call(this.elem
, event
, this.fn
.data
) === false )
4234 return (stop
= false);
4240 function liveConvert(type
, selector
){
4241 return ["live", type
, selector
.replace(/\./g, "`").replace(/ /g
, "|")].join(".");
4247 // Handle when the DOM is ready
4250 /// This method is internal.
4254 // Make sure that the DOM is not already loaded
4255 if ( !jQuery
.isReady
) {
4256 // Remember that the DOM is ready
4257 jQuery
.isReady
= true;
4259 // If there are functions bound, to execute
4260 if ( jQuery
.readyList
) {
4261 // Execute all of them
4262 jQuery
.each( jQuery
.readyList
, function(){
4263 this.call( document
, jQuery
);
4266 // Reset the list of functions
4267 jQuery
.readyList
= null;
4270 // Trigger any bound ready events
4271 jQuery(document
).triggerHandler("ready");
4276 var readyBound
= false;
4278 function bindReady(){
4279 if ( readyBound
) return;
4282 // Mozilla, Opera and webkit nightlies currently support this event
4283 if ( document
.addEventListener
) {
4284 // Use the handy event callback
4285 document
.addEventListener( "DOMContentLoaded", function(){
4286 document
.removeEventListener( "DOMContentLoaded", arguments
.callee
, false );
4290 // If IE event model is used
4291 } else if ( document
.attachEvent
) {
4292 // ensure firing before onload,
4293 // maybe late but safe also for iframes
4294 document
.attachEvent("onreadystatechange", function(){
4295 if ( document
.readyState
=== "complete" ) {
4296 document
.detachEvent( "onreadystatechange", arguments
.callee
);
4301 // If IE and not an iframe
4302 // continually check to see if the document is ready
4303 if ( document
.documentElement
.doScroll
&& window
== window
.top
) (function(){
4304 if ( jQuery
.isReady
) return;
4307 // If IE is used, use the trick by Diego Perini
4308 // http://javascript.nwbox.com/IEContentLoaded/
4309 document
.documentElement
.doScroll("left");
4311 setTimeout( arguments
.callee
, 0 );
4315 // and execute any waiting functions
4320 // A fallback to window.onload, that will always work
4321 jQuery
.event
.add( window
, "load", jQuery
.ready
);
4324 // [vsdoc] The following section has been denormalized from original sources for IntelliSense.
4326 jQuery
.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
4327 "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," +
4328 "change,select,submit,keydown,keypress,keyup,error").split(","), function(i
, name
){
4330 // Handle event binding
4331 jQuery
.fn
[name
] = function(fn
){
4332 return fn
? this.bind(name
, fn
) : this.trigger(name
);
4336 jQuery
.fn
["blur"] = function(fn
) {
4338 /// 1: blur() - Triggers the blur event of each matched element.
4339 /// 2: blur(fn) - Binds a function to the blur event of each matched element.
4341 /// <param name="fn" type="Function">The function to execute.</param>
4342 /// <returns type="jQuery" />
4343 return fn
? this.bind("blur", fn
) : this.trigger(name
);
4346 jQuery
.fn
["focus"] = function(fn
) {
4348 /// 1: focus() - Triggers the focus event of each matched element.
4349 /// 2: focus(fn) - Binds a function to the focus event of each matched element.
4351 /// <param name="fn" type="Function">The function to execute.</param>
4352 /// <returns type="jQuery" />
4353 return fn
? this.bind("focus", fn
) : this.trigger(name
);
4356 jQuery
.fn
["load"] = function(fn
) {
4358 /// 1: load() - Triggers the load event of each matched element.
4359 /// 2: load(fn) - Binds a function to the load event of each matched element.
4361 /// <param name="fn" type="Function">The function to execute.</param>
4362 /// <returns type="jQuery" />
4363 return fn
? this.bind("load", fn
) : this.trigger(name
);
4366 jQuery
.fn
["resize"] = function(fn
) {
4368 /// 1: resize() - Triggers the resize event of each matched element.
4369 /// 2: resize(fn) - Binds a function to the resize event of each matched element.
4371 /// <param name="fn" type="Function">The function to execute.</param>
4372 /// <returns type="jQuery" />
4373 return fn
? this.bind("resize", fn
) : this.trigger(name
);
4376 jQuery
.fn
["scroll"] = function(fn
) {
4378 /// 1: scroll() - Triggers the scroll event of each matched element.
4379 /// 2: scroll(fn) - Binds a function to the scroll event of each matched element.
4381 /// <param name="fn" type="Function">The function to execute.</param>
4382 /// <returns type="jQuery" />
4383 return fn
? this.bind("scroll", fn
) : this.trigger(name
);
4386 jQuery
.fn
["unload"] = function(fn
) {
4388 /// 1: unload() - Triggers the unload event of each matched element.
4389 /// 2: unload(fn) - Binds a function to the unload event of each matched element.
4391 /// <param name="fn" type="Function">The function to execute.</param>
4392 /// <returns type="jQuery" />
4393 return fn
? this.bind("unload", fn
) : this.trigger(name
);
4396 jQuery
.fn
["click"] = function(fn
) {
4398 /// 1: click() - Triggers the click event of each matched element.
4399 /// 2: click(fn) - Binds a function to the click event of each matched element.
4401 /// <param name="fn" type="Function">The function to execute.</param>
4402 /// <returns type="jQuery" />
4403 return fn
? this.bind("click", fn
) : this.trigger(name
);
4406 jQuery
.fn
["dblclick"] = function(fn
) {
4408 /// 1: dblclick() - Triggers the dblclick event of each matched element.
4409 /// 2: dblclick(fn) - Binds a function to the dblclick event of each matched element.
4411 /// <param name="fn" type="Function">The function to execute.</param>
4412 /// <returns type="jQuery" />
4413 return fn
? this.bind("dblclick", fn
) : this.trigger(name
);
4416 jQuery
.fn
["mousedown"] = function(fn
) {
4418 /// Binds a function to the mousedown event of each matched element.
4420 /// <param name="fn" type="Function">The function to execute.</param>
4421 /// <returns type="jQuery" />
4422 return fn
? this.bind("mousedown", fn
) : this.trigger(name
);
4425 jQuery
.fn
["mouseup"] = function(fn
) {
4427 /// Bind a function to the mouseup event of each matched element.
4429 /// <param name="fn" type="Function">The function to execute.</param>
4430 /// <returns type="jQuery" />
4431 return fn
? this.bind("mouseup", fn
) : this.trigger(name
);
4434 jQuery
.fn
["mousemove"] = function(fn
) {
4436 /// Bind a function to the mousemove event of each matched element.
4438 /// <param name="fn" type="Function">The function to execute.</param>
4439 /// <returns type="jQuery" />
4440 return fn
? this.bind("mousemove", fn
) : this.trigger(name
);
4443 jQuery
.fn
["mouseover"] = function(fn
) {
4445 /// Bind a function to the mouseover event of each matched element.
4447 /// <param name="fn" type="Function">The function to execute.</param>
4448 /// <returns type="jQuery" />
4449 return fn
? this.bind("mouseover", fn
) : this.trigger(name
);
4452 jQuery
.fn
["mouseout"] = function(fn
) {
4454 /// Bind a function to the mouseout event of each matched element.
4456 /// <param name="fn" type="Function">The function to execute.</param>
4457 /// <returns type="jQuery" />
4458 return fn
? this.bind("mouseout", fn
) : this.trigger(name
);
4461 jQuery
.fn
["mouseenter"] = function(fn
) {
4463 /// Bind a function to the mouseenter event of each matched element.
4465 /// <param name="fn" type="Function">The function to execute.</param>
4466 /// <returns type="jQuery" />
4467 return fn
? this.bind("mouseenter", fn
) : this.trigger(name
);
4470 jQuery
.fn
["mouseleave"] = function(fn
) {
4472 /// Bind a function to the mouseleave event of each matched element.
4474 /// <param name="fn" type="Function">The function to execute.</param>
4475 /// <returns type="jQuery" />
4476 return fn
? this.bind("mouseleave", fn
) : this.trigger(name
);
4479 jQuery
.fn
["change"] = function(fn
) {
4481 /// 1: change() - Triggers the change event of each matched element.
4482 /// 2: change(fn) - Binds a function to the change event of each matched element.
4484 /// <param name="fn" type="Function">The function to execute.</param>
4485 /// <returns type="jQuery" />
4486 return fn
? this.bind("change", fn
) : this.trigger(name
);
4489 jQuery
.fn
["select"] = function(fn
) {
4491 /// 1: select() - Triggers the select event of each matched element.
4492 /// 2: select(fn) - Binds a function to the select event of each matched element.
4494 /// <param name="fn" type="Function">The function to execute.</param>
4495 /// <returns type="jQuery" />
4496 return fn
? this.bind("select", fn
) : this.trigger(name
);
4499 jQuery
.fn
["submit"] = function(fn
) {
4501 /// 1: submit() - Triggers the submit event of each matched element.
4502 /// 2: submit(fn) - Binds a function to the submit event of each matched element.
4504 /// <param name="fn" type="Function">The function to execute.</param>
4505 /// <returns type="jQuery" />
4506 return fn
? this.bind("submit", fn
) : this.trigger(name
);
4509 jQuery
.fn
["keydown"] = function(fn
) {
4511 /// 1: keydown() - Triggers the keydown event of each matched element.
4512 /// 2: keydown(fn) - Binds a function to the keydown event of each matched element.
4514 /// <param name="fn" type="Function">The function to execute.</param>
4515 /// <returns type="jQuery" />
4516 return fn
? this.bind("keydown", fn
) : this.trigger(name
);
4519 jQuery
.fn
["keypress"] = function(fn
) {
4521 /// 1: keypress() - Triggers the keypress event of each matched element.
4522 /// 2: keypress(fn) - Binds a function to the keypress event of each matched element.
4524 /// <param name="fn" type="Function">The function to execute.</param>
4525 /// <returns type="jQuery" />
4526 return fn
? this.bind("keypress", fn
) : this.trigger(name
);
4529 jQuery
.fn
["keyup"] = function(fn
) {
4531 /// 1: keyup() - Triggers the keyup event of each matched element.
4532 /// 2: keyup(fn) - Binds a function to the keyup event of each matched element.
4534 /// <param name="fn" type="Function">The function to execute.</param>
4535 /// <returns type="jQuery" />
4536 return fn
? this.bind("keyup", fn
) : this.trigger(name
);
4539 jQuery
.fn
["error"] = function(fn
) {
4541 /// 1: error() - Triggers the error event of each matched element.
4542 /// 2: error(fn) - Binds a function to the error event of each matched element.
4544 /// <param name="fn" type="Function">The function to execute.</param>
4545 /// <returns type="jQuery" />
4546 return fn
? this.bind("error", fn
) : this.trigger(name
);
4549 // Prevent memory leaks in IE
4550 // And prevent errors on refresh with events like mouseover in other browsers
4551 // Window isn't included so as not to unbind existing unload events
4552 jQuery( window
).bind( 'unload', function(){
4553 for ( var id
in jQuery
.cache
)
4555 if ( id
!= 1 && jQuery
.cache
[ id
].handle
)
4556 jQuery
.event
.remove( jQuery
.cache
[ id
].handle
.elem
);
4559 // [vsdoc] The following function has been commented out for IntelliSense.
4562 // jQuery.support = {};
4564 // var root = document.documentElement,
4565 // script = document.createElement("script"),
4566 // div = document.createElement("div"),
4567 // id = "script" + (new Date).getTime();
4569 // div.style.display = "none";
4571 // div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';
4573 // var all = div.getElementsByTagName("*"),
4574 // a = div.getElementsByTagName("a")[0];
4576 // // Can't get basic test support
4577 // if ( !all || !all.length || !a ) {
4581 // jQuery.support = {
4582 // // IE strips leading whitespace when .innerHTML is used
4583 // leadingWhitespace: div.firstChild.nodeType == 3,
4585 // // Make sure that tbody elements aren't automatically inserted
4586 // // IE will insert them into empty tables
4587 // tbody: !div.getElementsByTagName("tbody").length,
4589 // // Make sure that you can get all elements in an <object> element
4590 // // IE 7 always returns no results
4591 // objectAll: !!div.getElementsByTagName("object")[0]
4592 // .getElementsByTagName("*").length,
4594 // // Make sure that link elements get serialized correctly by innerHTML
4595 // // This requires a wrapper element in IE
4596 // htmlSerialize: !!div.getElementsByTagName("link").length,
4598 // // Get the style information from getAttribute
4599 // // (IE uses .cssText insted)
4600 // style: /red/.test( a.getAttribute("style") ),
4602 // // Make sure that URLs aren't manipulated
4603 // // (IE normalizes it by default)
4604 // hrefNormalized: a.getAttribute("href") === "/a",
4606 // // Make sure that element opacity exists
4607 // // (IE uses filter instead)
4608 // opacity: a.style.opacity === "0.5",
4610 // // Verify style float existence
4611 // // (IE uses styleFloat instead of cssFloat)
4612 // cssFloat: !!a.style.cssFloat,
4614 // // Will be defined later
4615 // scriptEval: false,
4616 // noCloneEvent: true,
4620 // script.type = "text/javascript";
4622 // script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
4625 // root.insertBefore( script, root.firstChild );
4627 // // Make sure that the execution of code works by injecting a script
4628 // // tag with appendChild/createTextNode
4629 // // (IE doesn't support this, fails, and uses .text instead)
4630 // if ( window[ id ] ) {
4631 // jQuery.support.scriptEval = true;
4632 // delete window[ id ];
4635 // root.removeChild( script );
4637 // if ( div.attachEvent && div.fireEvent ) {
4638 // div.attachEvent("onclick", function(){
4639 // // Cloning a node shouldn't copy over any
4640 // // bound event handlers (IE does this)
4641 // jQuery.support.noCloneEvent = false;
4642 // div.detachEvent("onclick", arguments.callee);
4644 // div.cloneNode(true).fireEvent("onclick");
4647 // // Figure out if the W3C box model works as expected
4648 // // document.body must exist before we can do this
4649 // jQuery(function(){
4650 // var div = document.createElement("div");
4651 // div.style.width = div.style.paddingLeft = "1px";
4653 // document.body.appendChild( div );
4654 // jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
4655 // document.body.removeChild( div ).style.display = 'none';
4659 // [vsdoc] The following function has been modified for IntelliSense.
4660 // var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";
4661 var styleFloat
= "cssFloat";
4666 "class": "className",
4667 "float": styleFloat
,
4668 cssFloat
: styleFloat
,
4669 styleFloat
: styleFloat
,
4670 readonly
: "readOnly",
4671 maxlength
: "maxLength",
4672 cellspacing
: "cellSpacing",
4674 tabindex
: "tabIndex"
4677 // Keep a copy of the old load
4678 _load
: jQuery
.fn
.load
,
4680 load: function( url
, params
, callback
) {
4682 /// Loads HTML from a remote file and injects it into the DOM. By default performs a GET request, but if parameters are included
4683 /// then a POST will be performed.
4685 /// <param name="url" type="String">The URL of the HTML page to load.</param>
4686 /// <param name="data" optional="true" type="Map">Key/value pairs that will be sent to the server.</param>
4687 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete. It should map function(responseText, textStatus, XMLHttpRequest) such that this maps the injected DOM element.</param>
4688 /// <returns type="jQuery" />
4690 if ( typeof url
!== "string" )
4691 return this._load( url
);
4693 var off
= url
.indexOf(" ");
4695 var selector
= url
.slice(off
, url
.length
);
4696 url
= url
.slice(0, off
);
4699 // Default to a GET request
4702 // If the second parameter was provided
4704 // If it's a function
4705 if ( jQuery
.isFunction( params
) ) {
4706 // We assume that it's the callback
4710 // Otherwise, build a param string
4711 } else if( typeof params
=== "object" ) {
4712 params
= jQuery
.param( params
);
4718 // Request the remote document
4724 complete: function(res
, status
){
4725 // If successful, inject the HTML into all the matched elements
4726 if ( status
== "success" || status
== "notmodified" )
4727 // See if a selector was specified
4728 self
.html( selector
?
4729 // Create a dummy div to hold the results
4731 // inject the contents of the document in, removing the scripts
4732 // to avoid any 'Permission Denied' errors in IE
4733 .append(res
.responseText
.replace(/<script(.|\s)*?\/script>/g, ""))
4735 // Locate the specified elements
4738 // If not, just inject the full result
4742 self
.each( callback
, [res
.responseText
, status
, res
] );
4748 serialize: function() {
4750 /// Serializes a set of input elements into a string of data.
4752 /// <returns type="String">The serialized result</returns>
4754 return jQuery
.param(this.serializeArray());
4756 serializeArray: function() {
4758 /// Serializes all forms and form elements but returns a JSON data structure.
4760 /// <returns type="String">A JSON data structure representing the serialized items.</returns>
4762 return this.map(function(){
4763 return this.elements
? jQuery
.makeArray(this.elements
) : this;
4766 return this.name
&& !this.disabled
&&
4767 (this.checked
|| /select|textarea/i.test(this.nodeName
) ||
4768 /text|hidden|password|search/i.test(this.type
));
4770 .map(function(i
, elem
){
4771 var val
= jQuery(this).val();
4772 return val
== null ? null :
4773 jQuery
.isArray(val
) ?
4774 jQuery
.map( val
, function(val
, i
){
4775 return {name
: elem
.name
, value
: val
};
4777 {name
: elem
.name
, value
: val
};
4782 // [vsdoc] The following section has been denormalized from original sources for IntelliSense.
4783 // Attach a bunch of functions for handling common AJAX events
4784 // jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
4785 // jQuery.fn[o] = function(f){
4786 // return this.bind(o, f);
4790 jQuery
.fn
["ajaxStart"] = function(callback
) {
4792 /// Attach a function to be executed whenever an AJAX request begins and there is none already active. This is an Ajax Event.
4794 /// <param name="callback" type="Function">The function to execute.</param>
4795 /// <returns type="jQuery" />
4796 return this.bind("ajaxStart", f
);
4799 jQuery
.fn
["ajaxStop"] = function(callback
) {
4801 /// Attach a function to be executed whenever all AJAX requests have ended. This is an Ajax Event.
4803 /// <param name="callback" type="Function">The function to execute.</param>
4804 /// <returns type="jQuery" />
4805 return this.bind("ajaxStop", f
);
4808 jQuery
.fn
["ajaxComplete"] = function(callback
) {
4810 /// Attach a function to be executed whenever an AJAX request completes. This is an Ajax Event.
4812 /// <param name="callback" type="Function">The function to execute.</param>
4813 /// <returns type="jQuery" />
4814 return this.bind("ajaxComplete", f
);
4817 jQuery
.fn
["ajaxError"] = function(callback
) {
4819 /// Attach a function to be executed whenever an AJAX request fails. This is an Ajax Event.
4821 /// <param name="callback" type="Function">The function to execute.</param>
4822 /// <returns type="jQuery" />
4823 return this.bind("ajaxError", f
);
4826 jQuery
.fn
["ajaxSuccess"] = function(callback
) {
4828 /// Attach a function to be executed whenever an AJAX request completes successfully. This is an Ajax Event.
4830 /// <param name="callback" type="Function">The function to execute.</param>
4831 /// <returns type="jQuery" />
4832 return this.bind("ajaxSuccess", f
);
4835 jQuery
.fn
["ajaxSend"] = function(callback
) {
4837 /// Attach a function to be executed before an AJAX request is sent. This is an Ajax Event.
4839 /// <param name="callback" type="Function">The function to execute.</param>
4840 /// <returns type="jQuery" />
4841 return this.bind("ajaxSend", f
);
4849 get: function( url
, data
, callback
, type
) {
4851 /// Loads a remote page using an HTTP GET request.
4853 /// <param name="url" type="String">The URL of the HTML page to load.</param>
4854 /// <param name="data" optional="true" type="Map">Key/value pairs that will be sent to the server.</param>
4855 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete. It should map function(responseText, textStatus) such that this maps the options for this AJAX request.</param>
4856 /// <param name="type" optional="true" type="String">Type of data to be returned to callback function. Valid valiues are xml, html, script, json, text, _default.</param>
4857 /// <returns type="XMLHttpRequest" />
4859 // shift arguments if data argument was ommited
4860 if ( jQuery
.isFunction( data
) ) {
4865 return jQuery
.ajax({
4874 getScript: function( url
, callback
) {
4876 /// Loads and executes a local JavaScript file using an HTTP GET request.
4878 /// <param name="url" type="String">The URL of the script to load.</param>
4879 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete. It should map function(data, textStatus) such that this maps the options for the AJAX request.</param>
4880 /// <returns type="XMLHttpRequest" />
4882 return jQuery
.get(url
, null, callback
, "script");
4885 getJSON: function( url
, data
, callback
) {
4887 /// Loads JSON data using an HTTP GET request.
4889 /// <param name="url" type="String">The URL of the JSON data to load.</param>
4890 /// <param name="data" optional="true" type="Map">Key/value pairs that will be sent to the server.</param>
4891 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete if the data is loaded successfully. It should map function(data, textStatus) such that this maps the options for this AJAX request.</param>
4892 /// <returns type="XMLHttpRequest" />
4894 return jQuery
.get(url
, data
, callback
, "json");
4897 post: function( url
, data
, callback
, type
) {
4899 /// Loads a remote page using an HTTP POST request.
4901 /// <param name="url" type="String">The URL of the HTML page to load.</param>
4902 /// <param name="data" optional="true" type="Map">Key/value pairs that will be sent to the server.</param>
4903 /// <param name="callback" optional="true" type="Function">The function called when the AJAX request is complete. It should map function(responseText, textStatus) such that this maps the options for this AJAX request.</param>
4904 /// <param name="type" optional="true" type="String">Type of data to be returned to callback function. Valid valiues are xml, html, script, json, text, _default.</param>
4905 /// <returns type="XMLHttpRequest" />
4907 if ( jQuery
.isFunction( data
) ) {
4912 return jQuery
.ajax({
4921 ajaxSetup: function( settings
) {
4923 /// Sets up global settings for AJAX requests.
4925 /// <param name="settings" type="Options">A set of key/value pairs that configure the default Ajax request.</param>
4927 jQuery
.extend( jQuery
.ajaxSettings
, settings
);
4934 contentType
: "application/x-www-form-urlencoded",
4943 // Create the request object; Microsoft failed to properly
4944 // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
4945 // This function can be overriden by calling jQuery.ajaxSetup
4947 return window
.ActiveXObject
? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
4950 xml
: "application/xml, text/xml",
4952 script
: "text/javascript, application/javascript",
4953 json
: "application/json, text/javascript",
4959 // Last-Modified header cache for next request
4962 ajax: function( s
) {
4964 /// Load a remote page using an HTTP request.
4968 // Extend the settings, but re-extend 's' so that it can be
4969 // checked again later (in the test suite, specifically)
4970 s
= jQuery
.extend(true, s
, jQuery
.extend(true, {}, jQuery
.ajaxSettings
, s
));
4972 var jsonp
, jsre
= /=\?(&|$)/g, status
, data
,
4973 type
= s
.type
.toUpperCase();
4975 // convert data if not already a string
4976 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" )
4977 s
.data
= jQuery
.param(s
.data
);
4979 // Handle JSONP Parameter Callbacks
4980 if ( s
.dataType
== "jsonp" ) {
4981 if ( type
== "GET" ) {
4982 if ( !s
.url
.match(jsre
) )
4983 s
.url
+= (s
.url
.match(/\?/) ? "&" : "?") + (s
.jsonp
|| "callback") + "=?";
4984 } else if ( !s
.data
|| !s
.data
.match(jsre
) )
4985 s
.data
= (s
.data
? s
.data
+ "&" : "") + (s
.jsonp
|| "callback") + "=?";
4986 s
.dataType
= "json";
4989 // Build temporary JSONP function
4990 if ( s
.dataType
== "json" && (s
.data
&& s
.data
.match(jsre
) || s
.url
.match(jsre
)) ) {
4991 jsonp
= "jsonp" + jsc
++;
4993 // Replace the =? sequence both in the query string and the data
4995 s
.data
= (s
.data
+ "").replace(jsre
, "=" + jsonp
+ "$1");
4996 s
.url
= s
.url
.replace(jsre
, "=" + jsonp
+ "$1");
4998 // We need to make sure
4999 // that a JSONP style response is executed properly
5000 s
.dataType
= "script";
5002 // Handle JSONP-style loading
5003 window
[ jsonp
] = function(tmp
){
5008 window
[ jsonp
] = undefined;
5009 try{ delete window
[ jsonp
]; } catch(e
){}
5011 head
.removeChild( script
);
5015 if ( s
.dataType
== "script" && s
.cache
== null )
5018 if ( s
.cache
=== false && type
== "GET" ) {
5020 // try replacing _= if it is there
5021 var ret
= s
.url
.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts
+ "$2");
5022 // if nothing was replaced, add timestamp to the end
5023 s
.url
= ret
+ ((ret
== s
.url
) ? (s
.url
.match(/\?/) ? "&" : "?") + "_=" + ts
: "");
5026 // If data is available, append data to url for get requests
5027 if ( s
.data
&& type
== "GET" ) {
5028 s
.url
+= (s
.url
.match(/\?/) ? "&" : "?") + s
.data
;
5030 // IE likes to send both get and post data, prevent this
5034 // Watch for a new set of requests
5035 if ( s
.global
&& ! jQuery
.active
++ )
5036 jQuery
.event
.trigger( "ajaxStart" );
5038 // Matches an absolute URL, and saves the domain
5039 var parts
= /^(\w+:)?\/\/([^\/?#]+)/.exec( s
.url
);
5041 // If we're requesting a remote document
5042 // and trying to load JSON or Script with a GET
5043 if ( s
.dataType
== "script" && type
== "GET" && parts
5044 && ( parts
[1] && parts
[1] != location
.protocol
|| parts
[2] != location
.host
)){
5046 var head
= document
.getElementsByTagName("head")[0];
5047 var script
= document
.createElement("script");
5049 if (s
.scriptCharset
)
5050 script
.charset
= s
.scriptCharset
;
5052 // Handle Script loading
5056 // Attach handlers for all browsers
5057 script
.onload
= script
.onreadystatechange = function(){
5058 if ( !done
&& (!this.readyState
||
5059 this.readyState
== "loaded" || this.readyState
== "complete") ) {
5064 // Handle memory leak in IE
5065 script
.onload
= script
.onreadystatechange
= null;
5066 head
.removeChild( script
);
5071 head
.appendChild(script
);
5073 // We handle everything using the script element injection
5077 var requestDone
= false;
5079 // Create the request object
5083 // Passing null username, generates a login popup on Opera (#2865)
5085 xhr
.open(type
, s
.url
, s
.async
, s
.username
, s
.password
);
5087 xhr
.open(type
, s
.url
, s
.async
);
5089 // Need an extra try/catch for cross domain requests in Firefox 3
5091 // Set the correct header, if data is being sent
5093 xhr
.setRequestHeader("Content-Type", s
.contentType
);
5095 // Set the If-Modified-Since header, if ifModified mode.
5097 xhr
.setRequestHeader("If-Modified-Since",
5098 jQuery
.lastModified
[s
.url
] || "Thu, 01 Jan 1970 00:00:00 GMT" );
5100 // Set header so the called script knows that it's an XMLHttpRequest
5101 xhr
.setRequestHeader("X-Requested-With", "XMLHttpRequest");
5103 // Set the Accepts header for the server, depending on the dataType
5104 xhr
.setRequestHeader("Accept", s
.dataType
&& s
.accepts
[ s
.dataType
] ?
5105 s
.accepts
[ s
.dataType
] + ", */*" :
5106 s
.accepts
._default
);
5109 // Allow custom headers/mimetypes and early abort
5110 if ( s
.beforeSend
&& s
.beforeSend(xhr
, s
) === false ) {
5111 // Handle the global AJAX counter
5112 if ( s
.global
&& ! --jQuery
.active
)
5113 jQuery
.event
.trigger( "ajaxStop" );
5114 // close opended socket
5120 jQuery
.event
.trigger("ajaxSend", [xhr
, s
]);
5122 // Wait for a response to come back
5123 var onreadystatechange = function(isTimeout
){
5124 // The request was aborted, clear the interval and decrement jQuery.active
5125 if (xhr
.readyState
== 0) {
5127 // clear poll interval
5128 clearInterval(ival
);
5130 // Handle the global AJAX counter
5131 if ( s
.global
&& ! --jQuery
.active
)
5132 jQuery
.event
.trigger( "ajaxStop" );
5134 // The transfer is complete and the data is available, or the request timed out
5135 } else if ( !requestDone
&& xhr
&& (xhr
.readyState
== 4 || isTimeout
== "timeout") ) {
5138 // clear poll interval
5140 clearInterval(ival
);
5144 status
= isTimeout
== "timeout" ? "timeout" :
5145 !jQuery
.httpSuccess( xhr
) ? "error" :
5146 s
.ifModified
&& jQuery
.httpNotModified( xhr
, s
.url
) ? "notmodified" :
5149 if ( status
== "success" ) {
5150 // Watch for, and catch, XML document parse errors
5152 // process the data (runs the xml through httpData regardless of callback)
5153 data
= jQuery
.httpData( xhr
, s
.dataType
, s
);
5155 status
= "parsererror";
5159 // Make sure that the request was successful or notmodified
5160 if ( status
== "success" ) {
5161 // Cache Last-Modified header, if ifModified mode.
5164 modRes
= xhr
.getResponseHeader("Last-Modified");
5165 } catch(e
) {} // swallow exception thrown by FF if header is not available
5167 if ( s
.ifModified
&& modRes
)
5168 jQuery
.lastModified
[s
.url
] = modRes
;
5170 // JSONP handles its own success callback
5174 jQuery
.handleError(s
, xhr
, status
);
5176 // Fire the complete handlers
5182 // Stop memory leaks
5189 // don't attach the handler to the request, just poll it instead
5190 var ival
= setInterval(onreadystatechange
, 13);
5193 if ( s
.timeout
> 0 )
5194 setTimeout(function(){
5195 // Check to see if the request is still happening
5196 if ( xhr
&& !requestDone
)
5197 onreadystatechange( "timeout" );
5205 jQuery
.handleError(s
, xhr
, null, e
);
5208 // firefox 1.5 doesn't fire statechange for sync requests
5210 onreadystatechange();
5213 // If a local callback was specified, fire it and pass it the data
5215 s
.success( data
, status
);
5217 // Fire the global callback
5219 jQuery
.event
.trigger( "ajaxSuccess", [xhr
, s
] );
5222 function complete(){
5225 s
.complete(xhr
, status
);
5227 // The request was completed
5229 jQuery
.event
.trigger( "ajaxComplete", [xhr
, s
] );
5231 // Handle the global AJAX counter
5232 if ( s
.global
&& ! --jQuery
.active
)
5233 jQuery
.event
.trigger( "ajaxStop" );
5236 // return XMLHttpRequest to allow aborting the request etc.
5240 handleError: function( s
, xhr
, status
, e
) {
5242 /// This method is internal.
5246 // If a local callback was specified, fire it
5247 if ( s
.error
) s
.error( xhr
, status
, e
);
5249 // Fire the global callback
5251 jQuery
.event
.trigger( "ajaxError", [xhr
, s
, e
] );
5254 // Counter for holding the number of active queries
5257 // Determines if an XMLHttpRequest was successful or not
5258 httpSuccess: function( xhr
) {
5260 /// This method is internal.
5265 // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
5266 return !xhr
.status
&& location
.protocol
== "file:" ||
5267 ( xhr
.status
>= 200 && xhr
.status
< 300 ) || xhr
.status
== 304 || xhr
.status
== 1223;
5272 // Determines if an XMLHttpRequest returns NotModified
5273 httpNotModified: function( xhr
, url
) {
5275 /// This method is internal.
5280 var xhrRes
= xhr
.getResponseHeader("Last-Modified");
5282 // Firefox always returns 200. check Last-Modified date
5283 return xhr
.status
== 304 || xhrRes
== jQuery
.lastModified
[url
];
5288 httpData: function( xhr
, type
, s
) {
5290 /// This method is internal.
5294 var ct
= xhr
.getResponseHeader("content-type"),
5295 xml
= type
== "xml" || !type
&& ct
&& ct
.indexOf("xml") >= 0,
5296 data
= xml
? xhr
.responseXML
: xhr
.responseText
;
5298 if ( xml
&& data
.documentElement
.tagName
== "parsererror" )
5299 throw "parsererror";
5301 // Allow a pre-filtering function to sanitize the response
5302 // s != null is checked to keep backwards compatibility
5303 if( s
&& s
.dataFilter
)
5304 data
= s
.dataFilter( data
, type
);
5306 // The filter can actually parse the response
5307 if( typeof data
=== "string" ){
5309 // If the type is "script", eval it in global context
5310 if ( type
== "script" )
5311 jQuery
.globalEval( data
);
5313 // Get the JavaScript object, if JSON is used.
5314 if ( type
== "json" )
5315 data
= window
["eval"]("(" + data
+ ")");
5321 // Serialize an array of form elements or a set of
5322 // key/values into a query string
5323 param: function( a
) {
5325 /// This method is internal. Use serialize() instead.
5327 /// <param name="a" type="Map">A map of key/value pairs to serialize into a string.</param>'
5328 /// <returns type="String" />
5333 function add( key
, value
){
5334 s
[ s
.length
] = encodeURIComponent(key
) + '=' + encodeURIComponent(value
);
5337 // If an array was passed in, assume that it is an array
5339 if ( jQuery
.isArray(a
) || a
.jquery
)
5340 // Serialize the form elements
5341 jQuery
.each( a
, function(){
5342 add( this.name
, this.value
);
5345 // Otherwise, assume that it's an object of key/value pairs
5347 // Serialize the key/values
5349 // If the value is an array then the key names need to be repeated
5350 if ( jQuery
.isArray(a
[j
]) )
5351 jQuery
.each( a
[j
], function(){
5355 add( j
, jQuery
.isFunction(a
[j
]) ? a
[j
]() : a
[j
] );
5357 // Return the resulting serialization
5358 return s
.join("&").replace(/%20/g, "+");
5362 var elemdisplay
= {},
5365 // height animations
5366 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
5368 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
5369 // opacity animations
5373 function genFx( type
, num
){
5375 jQuery
.each( fxAttrs
.concat
.apply([], fxAttrs
.slice(0,num
)), function(){
5382 show: function(speed
,callback
){
5384 /// Show all matched elements using a graceful animation and firing an optional callback after completion.
5386 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5387 /// the number of milliseconds to run the animation</param>
5388 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5389 /// <returns type="jQuery" />
5392 return this.animate( genFx("show", 3), speed
, callback
);
5394 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ){
5395 var old
= jQuery
.data(this[i
], "olddisplay");
5397 this[i
].style
.display
= old
|| "";
5399 if ( jQuery
.css(this[i
], "display") === "none" ) {
5400 var tagName
= this[i
].tagName
, display
;
5402 if ( elemdisplay
[ tagName
] ) {
5403 display
= elemdisplay
[ tagName
];
5405 var elem
= jQuery("<" + tagName
+ " />").appendTo("body");
5407 display
= elem
.css("display");
5408 if ( display
=== "none" )
5413 elemdisplay
[ tagName
] = display
;
5416 jQuery
.data(this[i
], "olddisplay", display
);
5420 // Set the display of the elements in a second loop
5421 // to avoid the constant reflow
5422 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ){
5423 this[i
].style
.display
= jQuery
.data(this[i
], "olddisplay") || "";
5430 hide: function(speed
,callback
){
5432 /// Hides all matched elements using a graceful animation and firing an optional callback after completion.
5434 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5435 /// the number of milliseconds to run the animation</param>
5436 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5437 /// <returns type="jQuery" />
5440 return this.animate( genFx("hide", 3), speed
, callback
);
5442 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ){
5443 var old
= jQuery
.data(this[i
], "olddisplay");
5444 if ( !old
&& old
!== "none" )
5445 jQuery
.data(this[i
], "olddisplay", jQuery
.css(this[i
], "display"));
5448 // Set the display of the elements in a second loop
5449 // to avoid the constant reflow
5450 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ){
5451 this[i
].style
.display
= "none";
5458 // Save the old toggle function
5459 _toggle
: jQuery
.fn
.toggle
,
5461 toggle: function( fn
, fn2
){
5463 /// Toggles displaying each of the set of matched elements.
5465 /// <returns type="jQuery" />
5467 var bool
= typeof fn
=== "boolean";
5469 return jQuery
.isFunction(fn
) && jQuery
.isFunction(fn2
) ?
5470 this._toggle
.apply( this, arguments
) :
5471 fn
== null || bool
?
5472 this.each(function(){
5473 var state
= bool
? fn
: jQuery(this).is(":hidden");
5474 jQuery(this)[ state
? "show" : "hide" ]();
5476 this.animate(genFx("toggle", 3), fn
, fn2
);
5479 fadeTo: function(speed
,to
,callback
){
5481 /// Fades the opacity of all matched elements to a specified opacity.
5483 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5484 /// the number of milliseconds to run the animation</param>
5485 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5486 /// <returns type="jQuery" />
5487 return this.animate({opacity
: to
}, speed
, callback
);
5490 animate: function( prop
, speed
, easing
, callback
) {
5492 /// A function for making custom animations.
5494 /// <param name="prop" type="Options">A set of style attributes that you wish to animate and to what end.</param>
5495 /// <param name="speed" optional="true" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5496 /// the number of milliseconds to run the animation</param>
5497 /// <param name="easing" optional="true" type="String">The name of the easing effect that you want to use. There are two built-in values, 'linear' and 'swing'.</param>
5498 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5499 /// <returns type="jQuery" />
5501 var optall
= jQuery
.speed(speed
, easing
, callback
);
5503 return this[ optall
.queue
=== false ? "each" : "queue" ](function(){
5505 var opt
= jQuery
.extend({}, optall
), p
,
5506 hidden
= this.nodeType
== 1 && jQuery(this).is(":hidden"),
5510 if ( prop
[p
] == "hide" && hidden
|| prop
[p
] == "show" && !hidden
)
5511 return opt
.complete
.call(this);
5513 if ( ( p
== "height" || p
== "width" ) && this.style
) {
5514 // Store display property
5515 opt
.display
= jQuery
.css(this, "display");
5517 // Make sure that nothing sneaks out
5518 opt
.overflow
= this.style
.overflow
;
5522 if ( opt
.overflow
!= null )
5523 this.style
.overflow
= "hidden";
5525 opt
.curAnim
= jQuery
.extend({}, prop
);
5527 jQuery
.each( prop
, function(name
, val
){
5528 var e
= new jQuery
.fx( self
, opt
, name
);
5530 if ( /toggle|show|hide/.test(val
) )
5531 e
[ val
== "toggle" ? hidden
? "show" : "hide" : val
]( prop
);
5533 var parts
= val
.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
5534 start
= e
.cur(true) || 0;
5537 var end
= parseFloat(parts
[2]),
5538 unit
= parts
[3] || "px";
5540 // We need to compute starting value
5541 if ( unit
!= "px" ) {
5542 self
.style
[ name
] = (end
|| 1) + unit
;
5543 start
= ((end
|| 1) / e
.cur(true)) * start
;
5544 self
.style
[ name
] = start
+ unit
;
5547 // If a +=/-= token was provided, we're doing a relative animation
5549 end
= ((parts
[1] == "-=" ? -1 : 1) * end
) + start
;
5551 e
.custom( start
, end
, unit
);
5553 e
.custom( start
, val
, "" );
5557 // For JS strict compliance
5562 stop: function(clearQueue
, gotoEnd
){
5564 /// Stops all currently animations on the specified elements.
5566 /// <param name="clearQueue" optional="true" type="Boolean">True to clear animations that are queued to run.</param>
5567 /// <param name="gotoEnd" optional="true" type="Boolean">True to move the element value to the end of its animation target.</param>
5568 /// <returns type="jQuery" />
5570 var timers
= jQuery
.timers
;
5575 this.each(function(){
5576 // go in reverse order so anything added to the queue during the loop is ignored
5577 for ( var i
= timers
.length
- 1; i
>= 0; i
-- )
5578 if ( timers
[i
].elem
== this ) {
5580 // force the next step to be the last
5582 timers
.splice(i
, 1);
5586 // start the next in the queue if the last step wasn't forced
5595 // Generate shortcuts for custom animations
5597 // slideDown: genFx("show", 1),
5598 // slideUp: genFx("hide", 1),
5599 // slideToggle: genFx("toggle", 1),
5600 // fadeIn: { opacity: "show" },
5601 // fadeOut: { opacity: "hide" }
5602 // }, function( name, props ){
5603 // jQuery.fn[ name ] = function( speed, callback ){
5604 // return this.animate( props, speed, callback );
5608 // [vsdoc] The following section has been denormalized from original sources for IntelliSense.
5610 jQuery
.fn
.slideDown = function( speed
, callback
){
5612 /// Reveal all matched elements by adjusting their height.
5614 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5615 /// the number of milliseconds to run the animation</param>
5616 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5617 /// <returns type="jQuery" />
5618 return this.animate( genFx("show", 1), speed
, callback
);
5621 jQuery
.fn
.slideUp = function( speed
, callback
){
5623 /// Hiding all matched elements by adjusting their height.
5625 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5626 /// the number of milliseconds to run the animation</param>
5627 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5628 /// <returns type="jQuery" />
5629 return this.animate( genFx("hide", 1), speed
, callback
);
5632 jQuery
.fn
.slideToggle = function( speed
, callback
){
5634 /// Toggles the visibility of all matched elements by adjusting their height.
5636 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5637 /// the number of milliseconds to run the animation</param>
5638 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5639 /// <returns type="jQuery" />
5640 return this.animate( genFx("toggle", 1), speed
, callback
);
5643 jQuery
.fn
.fadeIn = function( speed
, callback
){
5645 /// Fades in all matched elements by adjusting their opacity.
5647 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5648 /// the number of milliseconds to run the animation</param>
5649 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5650 /// <returns type="jQuery" />
5651 return this.animate( { opacity
: "show" }, speed
, callback
);
5654 jQuery
.fn
.fadeOut = function( speed
, callback
){
5656 /// Fades the opacity of all matched elements to a specified opacity.
5658 /// <param name="speed" type="String">A string representing one of three predefined speeds ('slow', 'normal', or 'fast'), or
5659 /// the number of milliseconds to run the animation</param>
5660 /// <param name="callback" optional="true" type="Function">A function to be executed whenever the animation completes, once for each animated element. It should map function callback() such that this is the DOM element being animated.</param>
5661 /// <returns type="jQuery" />
5662 return this.animate( { opacity
: "hide" }, speed
, callback
);
5667 speed: function(speed
, easing
, fn
) {
5669 /// This member is internal.
5672 var opt
= typeof speed
=== "object" ? speed
: {
5673 complete
: fn
|| !fn
&& easing
||
5674 jQuery
.isFunction( speed
) && speed
,
5676 easing
: fn
&& easing
|| easing
&& !jQuery
.isFunction(easing
) && easing
5679 opt
.duration
= jQuery
.fx
.off
? 0 : typeof opt
.duration
=== "number" ? opt
.duration
:
5680 jQuery
.fx
.speeds
[opt
.duration
] || jQuery
.fx
.speeds
._default
;
5683 opt
.old
= opt
.complete
;
5684 opt
.complete = function(){
5685 if ( opt
.queue
!== false )
5686 jQuery(this).dequeue();
5687 if ( jQuery
.isFunction( opt
.old
) )
5688 opt
.old
.call( this );
5695 linear: function( p
, n
, firstNum
, diff
) {
5697 /// This member is internal.
5700 return firstNum
+ diff
* p
;
5702 swing: function( p
, n
, firstNum
, diff
) {
5704 /// This member is internal.
5707 return ((-Math
.cos(p
*Math
.PI
)/2) + 0.5) * diff
+ firstNum
;
5713 fx: function( elem
, options
, prop
){
5715 /// This member is internal.
5718 this.options
= options
;
5722 if ( !options
.orig
)
5728 jQuery
.fx
.prototype = {
5730 // Simple function for setting a style value
5733 /// This member is internal.
5736 if ( this.options
.step
)
5737 this.options
.step
.call( this.elem
, this.now
, this );
5739 (jQuery
.fx
.step
[this.prop
] || jQuery
.fx
.step
._default
)( this );
5741 // Set display property to block for height/width animations
5742 if ( ( this.prop
== "height" || this.prop
== "width" ) && this.elem
.style
)
5743 this.elem
.style
.display
= "block";
5746 // Get the current size
5747 cur: function(force
){
5749 /// This member is internal.
5752 if ( this.elem
[this.prop
] != null && (!this.elem
.style
|| this.elem
.style
[this.prop
] == null) )
5753 return this.elem
[ this.prop
];
5755 var r
= parseFloat(jQuery
.css(this.elem
, this.prop
, force
));
5756 return r
&& r
> -10000 ? r
: parseFloat(jQuery
.curCSS(this.elem
, this.prop
)) || 0;
5759 // Start an animation from one number to another
5760 custom: function(from, to
, unit
){
5761 this.startTime
= now();
5764 this.unit
= unit
|| this.unit
|| "px";
5765 this.now
= this.start
;
5766 this.pos
= this.state
= 0;
5769 function t(gotoEnd
){
5770 return self
.step(gotoEnd
);
5775 if ( t() && jQuery
.timers
.push(t
) && !timerId
) {
5776 timerId
= setInterval(function(){
5777 var timers
= jQuery
.timers
;
5779 for ( var i
= 0; i
< timers
.length
; i
++ )
5781 timers
.splice(i
--, 1);
5783 if ( !timers
.length
) {
5784 clearInterval( timerId
);
5785 timerId
= undefined;
5791 // Simple 'show' function
5794 /// Displays each of the set of matched elements if they are hidden.
5796 // Remember where we started, so that we can go back to it later
5797 this.options
.orig
[this.prop
] = jQuery
.attr( this.elem
.style
, this.prop
);
5798 this.options
.show
= true;
5800 // Begin the animation
5801 // Make sure that we start at a small width/height to avoid any
5803 this.custom(this.prop
== "width" || this.prop
== "height" ? 1 : 0, this.cur());
5805 // Start by showing the element
5806 jQuery(this.elem
).show();
5809 // Simple 'hide' function
5812 /// Hides each of the set of matched elements if they are shown.
5815 // Remember where we started, so that we can go back to it later
5816 this.options
.orig
[this.prop
] = jQuery
.attr( this.elem
.style
, this.prop
);
5817 this.options
.hide
= true;
5819 // Begin the animation
5820 this.custom(this.cur(), 0);
5823 // Each step of an animation
5824 step: function(gotoEnd
){
5826 /// This method is internal.
5831 if ( gotoEnd
|| t
>= this.options
.duration
+ this.startTime
) {
5832 this.now
= this.end
;
5833 this.pos
= this.state
= 1;
5836 this.options
.curAnim
[ this.prop
] = true;
5839 for ( var i
in this.options
.curAnim
)
5840 if ( this.options
.curAnim
[i
] !== true )
5844 if ( this.options
.display
!= null ) {
5845 // Reset the overflow
5846 this.elem
.style
.overflow
= this.options
.overflow
;
5848 // Reset the display
5849 this.elem
.style
.display
= this.options
.display
;
5850 if ( jQuery
.css(this.elem
, "display") == "none" )
5851 this.elem
.style
.display
= "block";
5854 // Hide the element if the "hide" operation was done
5855 if ( this.options
.hide
)
5856 jQuery(this.elem
).hide();
5858 // Reset the properties, if the item has been hidden or shown
5859 if ( this.options
.hide
|| this.options
.show
)
5860 for ( var p
in this.options
.curAnim
)
5861 jQuery
.attr(this.elem
.style
, p
, this.options
.orig
[p
]);
5863 // Execute the complete function
5864 this.options
.complete
.call( this.elem
);
5869 var n
= t
- this.startTime
;
5870 this.state
= n
/ this.options
.duration
;
5872 // Perform the easing function, defaults to swing
5873 this.pos
= jQuery
.easing
[this.options
.easing
|| (jQuery
.easing
.swing
? "swing" : "linear")](this.state
, n
, 0, 1, this.options
.duration
);
5874 this.now
= this.start
+ ((this.end
- this.start
) * this.pos
);
5876 // Perform the next step of the animation
5885 jQuery
.extend( jQuery
.fx
, {
5894 opacity: function(fx
){
5895 jQuery
.attr(fx
.elem
.style
, "opacity", fx
.now
);
5898 _default: function(fx
){
5899 if ( fx
.elem
.style
&& fx
.elem
.style
[ fx
.prop
] != null )
5900 fx
.elem
.style
[ fx
.prop
] = fx
.now
+ fx
.unit
;
5902 fx
.elem
[ fx
.prop
] = fx
.now
;
5906 if ( document
.documentElement
["getBoundingClientRect"] )
5907 jQuery
.fn
.offset = function() {
5909 /// Gets the current offset of the first matched element relative to the viewport.
5911 /// <returns type="Object">An object with two Integer properties, 'top' and 'left'.</returns>
5912 if ( !this[0] ) return { top
: 0, left
: 0 };
5913 if ( this[0] === this[0].ownerDocument
.body
) return jQuery
.offset
.bodyOffset( this[0] );
5914 var box
= this[0].getBoundingClientRect(), doc
= this[0].ownerDocument
, body
= doc
.body
, docElem
= doc
.documentElement
,
5915 clientTop
= docElem
.clientTop
|| body
.clientTop
|| 0, clientLeft
= docElem
.clientLeft
|| body
.clientLeft
|| 0,
5916 top
= box
.top
+ (self
.pageYOffset
|| jQuery
.boxModel
&& docElem
.scrollTop
|| body
.scrollTop
) - clientTop
,
5917 left
= box
.left
+ (self
.pageXOffset
|| jQuery
.boxModel
&& docElem
.scrollLeft
|| body
.scrollLeft
) - clientLeft
;
5918 return { top
: top
, left
: left
};
5921 jQuery
.fn
.offset = function() {
5923 /// Gets the current offset of the first matched element relative to the viewport.
5925 /// <returns type="Object">An object with two Integer properties, 'top' and 'left'.</returns>
5926 if ( !this[0] ) return { top
: 0, left
: 0 };
5927 if ( this[0] === this[0].ownerDocument
.body
) return jQuery
.offset
.bodyOffset( this[0] );
5928 jQuery
.offset
.initialized
|| jQuery
.offset
.initialize();
5930 var elem
= this[0], offsetParent
= elem
.offsetParent
, prevOffsetParent
= elem
,
5931 doc
= elem
.ownerDocument
, computedStyle
, docElem
= doc
.documentElement
,
5932 body
= doc
.body
, defaultView
= doc
.defaultView
,
5933 prevComputedStyle
= defaultView
.getComputedStyle(elem
, null),
5934 top
= elem
.offsetTop
, left
= elem
.offsetLeft
;
5936 while ( (elem
= elem
.parentNode
) && elem
!== body
&& elem
!== docElem
) {
5937 computedStyle
= defaultView
.getComputedStyle(elem
, null);
5938 top
-= elem
.scrollTop
, left
-= elem
.scrollLeft
;
5939 if ( elem
=== offsetParent
) {
5940 top
+= elem
.offsetTop
, left
+= elem
.offsetLeft
;
5941 if ( jQuery
.offset
.doesNotAddBorder
&& !(jQuery
.offset
.doesAddBorderForTableAndCells
&& /^t(able|d|h)$/i.test(elem
.tagName
)) )
5942 top
+= parseInt( computedStyle
.borderTopWidth
, 10) || 0,
5943 left
+= parseInt( computedStyle
.borderLeftWidth
, 10) || 0;
5944 prevOffsetParent
= offsetParent
, offsetParent
= elem
.offsetParent
;
5946 if ( jQuery
.offset
.subtractsBorderForOverflowNotVisible
&& computedStyle
.overflow
!== "visible" )
5947 top
+= parseInt( computedStyle
.borderTopWidth
, 10) || 0,
5948 left
+= parseInt( computedStyle
.borderLeftWidth
, 10) || 0;
5949 prevComputedStyle
= computedStyle
;
5952 if ( prevComputedStyle
.position
=== "relative" || prevComputedStyle
.position
=== "static" )
5953 top
+= body
.offsetTop
,
5954 left
+= body
.offsetLeft
;
5956 if ( prevComputedStyle
.position
=== "fixed" )
5957 top
+= Math
.max(docElem
.scrollTop
, body
.scrollTop
),
5958 left
+= Math
.max(docElem
.scrollLeft
, body
.scrollLeft
);
5960 return { top
: top
, left
: left
};
5964 initialize: function() {
5965 if ( this.initialized
) return;
5966 var body
= document
.body
, container
= document
.createElement('div'), innerDiv
, checkDiv
, table
, td
, rules
, prop
, bodyMarginTop
= body
.style
.marginTop
,
5967 html
= '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"cellpadding="0"cellspacing="0"><tr><td></td></tr></table>';
5969 rules
= { position
: 'absolute', top
: 0, left
: 0, margin
: 0, border
: 0, width
: '1px', height
: '1px', visibility
: 'hidden' };
5970 for ( prop
in rules
) container
.style
[prop
] = rules
[prop
];
5972 container
.innerHTML
= html
;
5973 body
.insertBefore(container
, body
.firstChild
);
5974 innerDiv
= container
.firstChild
, checkDiv
= innerDiv
.firstChild
, td
= innerDiv
.nextSibling
.firstChild
.firstChild
;
5976 this.doesNotAddBorder
= (checkDiv
.offsetTop
!== 5);
5977 this.doesAddBorderForTableAndCells
= (td
.offsetTop
=== 5);
5979 innerDiv
.style
.overflow
= 'hidden', innerDiv
.style
.position
= 'relative';
5980 this.subtractsBorderForOverflowNotVisible
= (checkDiv
.offsetTop
=== -5);
5982 body
.style
.marginTop
= '1px';
5983 this.doesNotIncludeMarginInBodyOffset
= (body
.offsetTop
=== 0);
5984 body
.style
.marginTop
= bodyMarginTop
;
5986 body
.removeChild(container
);
5987 this.initialized
= true;
5990 bodyOffset: function(body
) {
5991 jQuery
.offset
.initialized
|| jQuery
.offset
.initialize();
5992 var top
= body
.offsetTop
, left
= body
.offsetLeft
;
5993 if ( jQuery
.offset
.doesNotIncludeMarginInBodyOffset
)
5994 top
+= parseInt( jQuery
.curCSS(body
, 'marginTop', true), 10 ) || 0,
5995 left
+= parseInt( jQuery
.curCSS(body
, 'marginLeft', true), 10 ) || 0;
5996 return { top
: top
, left
: left
};
6002 position: function() {
6004 /// Gets the top and left positions of an element relative to its offset parent.
6006 /// <returns type="Object">An object with two integer properties, 'top' and 'left'.</returns>
6007 var left
= 0, top
= 0, results
;
6010 // Get *real* offsetParent
6011 var offsetParent
= this.offsetParent(),
6013 // Get correct offsets
6014 offset
= this.offset(),
6015 parentOffset
= /^body|html$/i.test(offsetParent
[0].tagName
) ? { top
: 0, left
: 0 } : offsetParent
.offset();
6017 // Subtract element margins
6018 // note: when an element has margin: auto the offsetLeft and marginLeft
6019 // are the same in Safari causing offset.left to incorrectly be 0
6020 offset
.top
-= num( this, 'marginTop' );
6021 offset
.left
-= num( this, 'marginLeft' );
6023 // Add offsetParent borders
6024 parentOffset
.top
+= num( offsetParent
, 'borderTopWidth' );
6025 parentOffset
.left
+= num( offsetParent
, 'borderLeftWidth' );
6027 // Subtract the two offsets
6029 top
: offset
.top
- parentOffset
.top
,
6030 left
: offset
.left
- parentOffset
.left
6037 offsetParent: function() {
6039 /// This method is internal.
6042 var offsetParent
= this[0].offsetParent
|| document
.body
;
6043 while ( offsetParent
&& (!/^body|html$/i.test(offsetParent
.tagName
) && jQuery
.css(offsetParent
, 'position') == 'static') )
6044 offsetParent
= offsetParent
.offsetParent
;
6045 return jQuery(offsetParent
);
6050 // Create scrollLeft and scrollTop methods
6051 jQuery
.each( ['Left'], function(i
, name
) {
6052 var method
= 'scroll' + name
;
6054 jQuery
.fn
[ method
] = function(val
) {
6056 /// Gets and optionally sets the scroll left offset of the first matched element.
6058 /// <param name="val" type="Number" integer="true" optional="true">A positive number representing the desired scroll left offset.</param>
6059 /// <returns type="Number" integer="true">The scroll left offset of the first matched element.</returns>
6060 if (!this[0]) return null;
6062 return val
!== undefined ?
6064 // Set the scroll offset
6065 this.each(function() {
6066 this == window
|| this == document
?
6068 !i
? val
: jQuery(window
).scrollLeft(),
6069 i
? val
: jQuery(window
).scrollTop()
6071 this[ method
] = val
;
6074 // Return the scroll offset
6075 this[0] == window
|| this[0] == document
?
6076 self
[ i
? 'pageYOffset' : 'pageXOffset' ] ||
6077 jQuery
.boxModel
&& document
.documentElement
[ method
] ||
6078 document
.body
[ method
] :
6083 // Create scrollLeft and scrollTop methods
6084 jQuery
.each( ['Top'], function(i
, name
) {
6085 var method
= 'scroll' + name
;
6087 jQuery
.fn
[ method
] = function(val
) {
6089 /// Gets and optionally sets the scroll top offset of the first matched element.
6091 /// <param name="val" type="Number" integer="true" optional="true">A positive number representing the desired scroll top offset.</param>
6092 /// <returns type="Number" integer="true">The scroll top offset of the first matched element.</returns>
6093 if (!this[0]) return null;
6095 return val
!== undefined ?
6097 // Set the scroll offset
6098 this.each(function() {
6099 this == window
|| this == document
?
6101 !i
? val
: jQuery(window
).scrollLeft(),
6102 i
? val
: jQuery(window
).scrollTop()
6104 this[ method
] = val
;
6107 // Return the scroll offset
6108 this[0] == window
|| this[0] == document
?
6109 self
[ i
? 'pageYOffset' : 'pageXOffset' ] ||
6110 jQuery
.boxModel
&& document
.documentElement
[ method
] ||
6111 document
.body
[ method
] :
6116 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
6117 jQuery
.each([ "Height" ], function(i
, name
){
6119 var tl
= i
? "Left" : "Top", // top or left
6120 br
= i
? "Right" : "Bottom", // bottom or right
6121 lower
= name
.toLowerCase();
6123 // innerHeight and innerWidth
6124 jQuery
.fn
["inner" + name
] = function(){
6126 /// Gets the inner height of the first matched element, excluding border but including padding.
6128 /// <returns type="Number" integer="true">The outer height of the first matched element.</returns>
6130 jQuery
.css( this[0], lower
, false, "padding" ) :
6134 // outerHeight and outerWidth
6135 jQuery
.fn
["outer" + name
] = function(margin
) {
6137 /// Gets the outer height of the first matched element, including border and padding by default.
6139 /// <param name="margins" type="Map">A set of key/value pairs that specify the options for the method.</param>
6140 /// <returns type="Number" integer="true">The outer height of the first matched element.</returns>
6142 jQuery
.css( this[0], lower
, false, margin
? "margin" : "border" ) :
6146 var type
= name
.toLowerCase();
6148 jQuery
.fn
[ type
] = function( size
) {
6150 /// Set the CSS height of every matched element. If no explicit unit
6151 /// was specified (like 'em' or '%') then "px" is added to the width. If no parameter is specified, it gets
6152 /// the current computed pixel height of the first matched element.
6155 /// <returns type="jQuery" type="jQuery" />
6156 /// <param name="cssProperty" type="String">
6157 /// Set the CSS property to the specified value. Omit to get the value of the first matched element.
6160 // Get window width or height
6161 return this[0] == window
?
6162 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
6163 document
.compatMode
== "CSS1Compat" && document
.documentElement
[ "client" + name
] ||
6164 document
.body
[ "client" + name
] :
6166 // Get document width or height
6167 this[0] == document
?
6168 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
6170 document
.documentElement
["client" + name
],
6171 document
.body
["scroll" + name
], document
.documentElement
["scroll" + name
],
6172 document
.body
["offset" + name
], document
.documentElement
["offset" + name
]
6175 // Get or set width or height on the element
6176 size
=== undefined ?
6177 // Get width or height on the element
6178 (this.length
? jQuery
.css( this[0], type
) : null) :
6180 // Set the width or height on the element (default to pixels if value is unitless)
6181 this.css( type
, typeof size
=== "string" ? size
: size
+ "px" );
6186 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
6187 jQuery
.each([ "Width" ], function(i
, name
){
6189 var tl
= i
? "Left" : "Top", // top or left
6190 br
= i
? "Right" : "Bottom", // bottom or right
6191 lower
= name
.toLowerCase();
6193 // innerHeight and innerWidth
6194 jQuery
.fn
["inner" + name
] = function(){
6196 /// Gets the inner width of the first matched element, excluding border but including padding.
6198 /// <returns type="Number" integer="true">The outer width of the first matched element.</returns>
6200 jQuery
.css( this[0], lower
, false, "padding" ) :
6204 // outerHeight and outerWidth
6205 jQuery
.fn
["outer" + name
] = function(margin
) {
6207 /// Gets the outer width of the first matched element, including border and padding by default.
6209 /// <param name="margins" type="Map">A set of key/value pairs that specify the options for the method.</param>
6210 /// <returns type="Number" integer="true">The outer width of the first matched element.</returns>
6212 jQuery
.css( this[0], lower
, false, margin
? "margin" : "border" ) :
6216 var type
= name
.toLowerCase();
6218 jQuery
.fn
[ type
] = function( size
) {
6220 /// Set the CSS width of every matched element. If no explicit unit
6221 /// was specified (like 'em' or '%') then "px" is added to the width. If no parameter is specified, it gets
6222 /// the current computed pixel width of the first matched element.
6225 /// <returns type="jQuery" type="jQuery" />
6226 /// <param name="cssProperty" type="String">
6227 /// Set the CSS property to the specified value. Omit to get the value of the first matched element.
6230 // Get window width or height
6231 return this[0] == window
?
6232 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
6233 document
.compatMode
== "CSS1Compat" && document
.documentElement
[ "client" + name
] ||
6234 document
.body
[ "client" + name
] :
6236 // Get document width or height
6237 this[0] == document
?
6238 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
6240 document
.documentElement
["client" + name
],
6241 document
.body
["scroll" + name
], document
.documentElement
["scroll" + name
],
6242 document
.body
["offset" + name
], document
.documentElement
["offset" + name
]
6245 // Get or set width or height on the element
6246 size
=== undefined ?
6247 // Get width or height on the element
6248 (this.length
? jQuery
.css( this[0], type
) : null) :
6250 // Set the width or height on the element (default to pixels if value is unitless)
6251 this.css( type
, typeof size
=== "string" ? size
: size
+ "px" );